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

Fix expanding the sidebar preventing hotkeys from working immediately #6410

Merged
merged 3 commits into from
Aug 17, 2022

Conversation

hotzenklotz
Copy link
Member

@hotzenklotz hotzenklotz commented Aug 17, 2022

This PR fixes a bug whereby expanding/collpasing the sidebar using the little icon buttons would make the main XYZ viewports lose focs/not respond to keyboard inputs anymore. Instead of having to click in the viewport to restore focs and continue using the keyboard hotkeys this now should work without any addtional click/refocusing.

Techical details:

  • It seems to me that the first blur() call only every blurred the
    element of the icon itself. For some reasons, the surround button element still retained focus/control. By also calling blur()onthe parent button element the issue resolved itself.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Expand/Collapse sidebar via button
  • Press any hotkey, e.g. f or SPACE, and observe that the intended behavior, e.g. movement, occurs

Issues:


(Please delete unneeded items, merge only when none are left open)

@hotzenklotz hotzenklotz self-assigned this Aug 17, 2022
@hotzenklotz hotzenklotz changed the title fix expanding the sidebar blocking hotkeys Fix expanding the sidebar preventing hotkeys from working immediately Aug 17, 2022
Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

thanks for digging into this!

Comment on lines 48 to -49
// @ts-expect-error ts-migrate(2339) FIXME: Property 'blur' does not exist on type 'EventTarge... Remove this comment to see the full error message
event.target.blur();
Copy link
Member

Choose a reason for hiding this comment

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

I think this blur() can be removed, as it probably doesn't do anything. As far as I know, only one blur will have an effect, since only one element can have the page focus. I also just tested it and the second blur seems to be enough to solve the issue 🎉

Copy link
Member

Choose a reason for hiding this comment

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

ah, it seems like it depends on where the user clicks exactly. sometimes the inner element gets the focus and sometimes the outer element. this is why both blurs make sense (however, with a slightly differing explanation than in your PR :)).

@hotzenklotz hotzenklotz enabled auto-merge (squash) August 17, 2022 15:44
@hotzenklotz hotzenklotz merged commit 22980c2 into master Aug 17, 2022
@hotzenklotz hotzenklotz deleted the fix-sidebar-blocking-hotkeys branch August 17, 2022 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts don't work after using button to collapse/expand sidebars
2 participants