Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Add proper padding when scrolling is added to bar gauge #32411

Closed
wants to merge 12 commits into from

Conversation

mckn
Copy link
Contributor

@mckn mckn commented Mar 29, 2021

What this PR does / why we need it:
Prior to this PR the scrollbar will hide the values in the bar gauge (and probably other visualizations). I added a setScrollable to apply the scrolling in the PanelChrome instead of in the vizRepeater which results in getting the padding in the right place for all browsers.

Which issue(s) this PR fixes:
Fixes #32083

Special notes for your reviewer:
I'm a bit concerned about adding the overflow: hidden to the .panel-content. Have done some testing and think it should be fine but still changing that component feels a bit dangerous.

@mckn mckn added this to the 7.5.2 milestone Mar 29, 2021
@mckn mckn requested review from torkelo and a team March 29, 2021 09:53
@mckn mckn added this to In Review in Frontend Platform Backlog via automation Mar 29, 2021
@mckn mckn self-assigned this Mar 29, 2021
@mckn mckn requested review from peterholmberg and removed request for a team March 29, 2021 09:53
@@ -102,11 +102,22 @@ div.flot-text {
width: 100%;
flex-grow: 1;
height: calc(100% - #{$panel-header-height});
overflow: hidden;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this feels a bit dangerous. Do you know about any use cases that might introduce a bug by adding this code? @torkelo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it breaks the dropdown select in Table panel, if we had a proper portal for Select component that could solve that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, damn...so I need to rethink this a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torkelo I changed so we use the portal functionality of react-select...not sure if this is the best way to proceed but I didn't need to do so much work to get it in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you think this is something we should proceed with. I will wait with fixing the tests until I got a 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess we want to support horizontal scrolling as well.

margin-bottom: $panel-padding;
}

&--no-padding.panel-content--scrollable-y {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: can I write this in some better way using sass?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&--no-padding.panel-content--scrollable-y {
&--no-padding#{&}--scrollable-y {

might do the trick :)

@mckn mckn modified the milestones: 7.5.2, 7.5.3 Mar 29, 2021
@mckn mckn requested a review from dprokop March 30, 2021 13:51
@mckn
Copy link
Contributor Author

mckn commented Mar 31, 2021

Summary:
When I changed the .panel-content to have overflow: hidden the selector stopped working e.g. in the scenario below. I fixed that by changing so we render the select menu in a portal.

Skärmavbild 2021-03-31 kl  10 58 25

Skärmavbild 2021-03-31 kl  10 49 39

However that resulted in the following issue in scenarios where we have a selector in a modal. That was solved by increasing the zIndex of the select menu portal to same as the modal.

Skärmavbild 2021-03-31 kl  10 57 02

Skärmavbild 2021-03-31 kl  10 51 18

The benefit of doing this is that we also squash a bunch of bugs where we use the selector in e.g. transformations etc where we currently have forced the selector to open downwards to prevent it from being hidden. But again, increasing the zIndex feels like a slippery slope.

I can think of one scenario (not sure if it is a valid one) where having the same (or higher) zIndex of the select menu portal and the modal is if we want to have an open select but still present a modal on top of it.

Would love some feedback on this @grafana/grafana-frontend-platform 🙏🏻

Edit
One thing that would make this a bit more flexible is that you can pass a property that indicates the context to the selector.

Edit 2
Not sure the @grafana/grafana-frontend-platform seems to work. So I will add @jackw @dprokop @hugohaggmark @torkelo @oscarkilhed ...

Comment on lines 277 to 282
const scrollableYMargin = plugin.scrollableY ? theme.panelPadding : 0;
const innerPanelHeight = height - headerHeight - chromePadding * 2 - PANEL_BORDER - scrollableYMargin;
const panelContentClassNames = classNames({
'panel-content': true,
'panel-content--no-padding': plugin.noPadding,
'panel-content--scrollable-y': plugin.scrollableY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need this special logic. and If plugin.scrollable is true we should wrap the component in a CustomScrollbar

@ifrost ifrost modified the milestones: 7.5.3, 7.5.4 Apr 7, 2021
@dprokop
Copy link
Member

dprokop commented Apr 8, 2021

@mckn this fixes the bar gauge issue 👌 But I see that adding portaling to select introduces the exact issues me and @tskarhed has been struggling with when we tried to add portaling:

  1. The panel edit selects are now positioned incorrectly, add scrollbar to the viewport and have fixed position relative to the window when scrolling. This applies to query editor selects and other selects as well
    Kapture 2021-04-08 at 09 18 25
    Kapture 2021-04-08 at 09 24 10

  2. The initial position of the select is incorrect:
    Kapture 2021-04-08 at 09 19 00

@tskarhed
Copy link
Contributor

tskarhed commented Apr 8, 2021

Wohoo! Select issues, don't you just love them? 😁

@mckn
Copy link
Contributor Author

mckn commented Apr 8, 2021

@mckn this fixes the bar gauge issue 👌 But I see that adding portaling to select introduces the exact issues me and @tskarhed has been struggling with when we tried to add portaling:

  1. There's sth wrong with Table's panel select:
    Kapture 2021-04-08 at 09 17 17
  2. The panel edit selects are now positioned incorrectly, add scrollbar to the viewport and have fixed position relative to the window when scrolling. This applies to query editor selects and other selects as well
    Kapture 2021-04-08 at 09 18 25
    Kapture 2021-04-08 at 09 24 10
  3. The initial position of the select is incorrect:
    Kapture 2021-04-08 at 09 19 00

Awesome findings @dprokop! I think for some of this issues we probably need to expose a "usePortal" property on the select component so you can control that depending on the context. It doesn't feel good but it might be the way to go.

@mckn
Copy link
Contributor Author

mckn commented Apr 9, 2021

Closing this one in favor of #32835 and #32833

@mckn mckn closed this Apr 9, 2021
Frontend Platform Backlog automation moved this from In Review to Done Apr 9, 2021
@osg-grafana osg-grafana changed the title Bugfix: making sure we have proper padding when scrolling is added to bar gauge Bugfix: Make sure we have proper padding when scrolling is added to bar gauge Apr 13, 2021
@osg-grafana osg-grafana changed the title Bugfix: Make sure we have proper padding when scrolling is added to bar gauge Bugfix: Add proper padding when scrolling is added to bar gauge Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bar gauge panel value hidden by vertical scroll bar in Firefox
8 participants