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

Prometheus: Query builder's Metric select is placing options below the viewport #85829

Closed
NWRichmond opened this issue Apr 9, 2024 · 0 comments · Fixed by #87150
Closed

Prometheus: Query builder's Metric select is placing options below the viewport #85829

NWRichmond opened this issue Apr 9, 2024 · 0 comments · Fixed by #87150
Assignees
Labels
datasource/Prometheus internal for issues made by grafanistas type/bug

Comments

@NWRichmond
Copy link
Contributor

The problem

In the Prometheus data source's query builder, the Metric select can display metric name options that extend past the viewport, which presents some challenges to users who aren't aware of this quirk:

  • Makes it difficult for users to find their metrics of interest
  • Gives the false impression that metric name results are incomplete

Note how the select is capable of displaying metric name options either above or below the select, but the select is displaying options past the bottom of the viewport when there is neither (a) enough space to display all results below the select, nor (b) sufficiently little space to trigger the select to display results above the select:

demo.select.with.apparent.missing.results.when.options.render.down.and.out.of.viewport.mov

Findings

The Prometheus data source's querybuilder/components/MetricSelect.tsx uses an <AsyncSelect /> component from @grafana/ui. As you can see in the Saga design system docs, the select should display results on top of the select when there isn't sufficient space to display results on the bottom:

demo.saga.select.default.behavior.of.options.dropdown.mov

So why isn't the Metric select working this way? Local testing suggests that it's because of the metric name loading strategy used in MetricsSelect.tsx's implementation of <AsyncSelect />. The select is initialized with empty options (or a single Metrics Modal option). When this happens, the options aren't long enough to trigger the select to display options above the select. The options are updated via onOpenMenu in a way that is contrary to the loading strategies described in the Saga design system and the react-select docs.

Fixing this likely requires updating the metric names loading strategy to align with the canonical approaches described in the Saga and react-select docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/Prometheus internal for issues made by grafanistas type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant