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

Explore: Be sure time range key bindings are mounted after clear #61892

Merged
merged 4 commits into from Jan 24, 2023

Conversation

gelicia
Copy link
Contributor

@gelicia gelicia commented Jan 20, 2023

What is this feature?

This was a bug caused by a couple different ways keybindings get added and removed.

On mounting the explore page, the time range keybindings are added here. The hook looks for changes in keybindings which does not hold any kind of state within itself so this only fires once. https://github.com/grafana/grafana/blob/main/public/app/features/explore/ExplorePage.tsx#L56

In Grafana Route, it will clear and re-init global key bindings on every route change https://github.com/grafana/grafana/blob/main/public/app/core/navigation/GrafanaRoute.tsx#L22

When navigating away from Explore, the time picker key bindings get wiped. When re-entering, they get re-added but before the clear and init function runs. Clear and init then wipes the re-added time range bindings.

Thanks to @ifrost for the fix! This moves the clear and reinit to the useLayoutEffect hook, which fires before individual components do, meaning the global keybindings are cleared and re-initialized, and then the explore page adds in the time range ones specific to explore.

Which issue(s) does this PR fix?:

Related to #56175

Special notes for your reviewer:

Replication Steps:

  1. Go to Explore and run a query. Type t z to trigger a time range key binding. You will notice the time picker will change from a relative time to an exact time.
  2. Go to home, or another non-explore page
  3. Go back to explore. Attempt to type t z again. Notice that nothing happens. With the fix, the time range keybindings work as expected.

@gelicia gelicia requested review from a team as code owners January 20, 2023 23:11
@gelicia gelicia requested review from ashharrison90 and yaelleC and removed request for a team January 20, 2023 23:11
@gelicia gelicia added this to the 9.4.0 milestone Jan 20, 2023
@gelicia gelicia added no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Jan 20, 2023
@github-actions
Copy link
Contributor

Backend code coverage report for PR #61892
No changes

@github-actions
Copy link
Contributor

Frontend code coverage report for PR #61892

Plugin Main PR Difference
explore 83.69% 83.69% 0%

Copy link
Contributor

@ifrost ifrost left a comment

Choose a reason for hiding this comment

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

Works as expected!

I left a comment to consider a different approach.

A few more questions:

  • Do we need to apply this fix to other places, e.g. Dashboards?
  • Can it be backported?

Partially fixes #56175

I don't think GitHub understands "partially" and will close the issue. Could you change it to "Related to #56175"?

public/app/features/explore/ExplorePage.tsx Outdated Show resolved Hide resolved
@gelicia gelicia requested a review from ifrost January 23, 2023 15:23
@gelicia gelicia added backport v9.3.x and removed no-backport Skip backport of PR labels Jan 23, 2023
@grafanabot
Copy link
Contributor

Hello @gelicia!
Backport pull requests need to be either:

  • Pull requests which address bugs,
  • Urgent fixes which need product approval, in order to get merged,
  • Docs changes.

Please, if the current pull request addresses a bug fix, label it with the type/bug label.
If it already has the product approval, please add the product-approved label. For docs changes, please add the type/docs label.
If none of the above applies, please consider removing the backport label and target the next major/minor release.
Thanks!

@gelicia
Copy link
Contributor Author

gelicia commented Jan 23, 2023

Do we need to apply this fix to other places, e.g. Dashboards?

I wasn't able to replicate it outside of explore.

Can it be backported?

It can - I changed it to backport it to 9.3 - but since this is a bug we found and as far as I know, has not been noticed widely, I would like to limit the backporting. I can change this if you disagree.

I don't think GitHub understands "partially" and will close the issue. Could you change it to "Related to #56175"?

Done!

@gelicia gelicia modified the milestones: 9.4.0, 9.3.4 Jan 24, 2023
@gelicia gelicia added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Jan 24, 2023
@gelicia gelicia merged commit 6ab79c4 into main Jan 24, 2023
@gelicia gelicia deleted the kristina/keybinding-bugs branch January 24, 2023 17:12
grafanabot pushed a commit that referenced this pull request Jan 24, 2023
)

* Add list of bindings for updating on change

* Revert "Add list of bindings for updating on change"

This reverts commit 0927073.

* Clear keybindings before component render

(cherry picked from commit 6ab79c4)
gelicia added a commit that referenced this pull request Jan 24, 2023
…lear (#62020)

Explore: Be sure time range key bindings are mounted after clear (#61892)

* Add list of bindings for updating on change

* Revert "Add list of bindings for updating on change"

This reverts commit 0927073.

* Clear keybindings before component render

(cherry picked from commit 6ab79c4)

Co-authored-by: Kristina <kristina.durivage@grafana.com>
gwdawson pushed a commit that referenced this pull request Jan 25, 2023
)

* Add list of bindings for updating on change

* Revert "Add list of bindings for updating on change"

This reverts commit 0927073.

* Clear keybindings before component render
baldm0mma pushed a commit that referenced this pull request Jan 26, 2023
)

* Add list of bindings for updating on change

* Revert "Add list of bindings for updating on change"

This reverts commit 0927073.

* Clear keybindings before component render
GuYounes pushed a commit to paul-wurth/BIXpert that referenced this pull request Feb 8, 2023
…lear (grafana#62020)

Explore: Be sure time range key bindings are mounted after clear (grafana#61892)

* Add list of bindings for updating on change

* Revert "Add list of bindings for updating on change"

This reverts commit 0927073.

* Clear keybindings before component render

(cherry picked from commit 6ab79c4)

Co-authored-by: Kristina <kristina.durivage@grafana.com>
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.

None yet

3 participants