Prometheus: Ensure values in metric selector are visible #87150
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this fix and why do we need it?
In the Prometheus data source's Query Builder, users must select a metric name. As described in #85829, the select can display options below the viewport. This happens because we are lazy-loading the options, and the component determines the placement (top/bottom) of options (based on available space above/below the select) before he options have finished loading. This presents a UX issue because users can get the false impression that metric names are missing from the select.
In addition to some light refactoring, this PR changes the select in the following ways:
<CustomScrollbar />
'sshowScrollIndicators
prop to indicate to the user when there are results above or below their current scroll position.Before
(on
main
)Note the various issues described above and in #85829.
demo.metrics.select.issues.in.before.state.mov
After
(on
85829/fix-prometheus-query-builder-metric-selector-display-beyond-viewport
)In the beginning of the video, note how the top and bottom of the options are greyed-out when the top-most and bottom-most options are out-of-view. This provides a visual cue to the user that they must scroll to reach the bottom or top. Next, note how regardless of how much space is available to render the select, the options are always visible.
demo.metrics.select.scroll.indicators.and.options.placement.without.border.changes.mov
Who is this feature for?
Prometheus data source users who rely on the Query Builder.
Which issue(s) does this PR fix?
This PR fixes #85829.
Special notes for your reviewer
N/A
Future work
These changes could also be applied elsewhere. We should examine any
<Select />
or<AsyncSelect />
that usesonOpenMenu
to lazy-load options, as they likely suffer from the same UX issues. In the Prometheus data source,LabelFilterItem.tsx
andLabelParamEditor.tsx
inpackages/grafana-prometheus/src/querybuilder/components
are candidates.Please check that:
(Not applicable)
If this is a pre-GA feature, it is behind a feature toggle.(Not applicable)
The docs are updated, and if this is a notable improvement, it's added to our What's New doc.