spacedrive icon indicating copy to clipboard operation
spacedrive copied to clipboard

Focus search bar on press Super+K

Open RockBacon9922 opened this issue 2 years ago • 6 comments

Implements focus on search bar when super+k is pressed. Hides the key combo hint when search bar is focused.

Closes #326

RockBacon9922 avatar Jul 07 '22 20:07 RockBacon9922

@RockBacon9922 is attempting to deploy a commit to the Spacedrive Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 07 '22 20:07 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
spacedrive-landing ✅ Ready (Inspect) Visit Preview Jul 17, 2022 at 0:40AM (UTC)
spacedrive-storybook ✅ Ready (Inspect) Visit Preview Jul 17, 2022 at 0:40AM (UTC)
spacedrive-web ✅ Ready (Inspect) Visit Preview Jul 17, 2022 at 0:40AM (UTC)

vercel[bot] avatar Jul 07 '22 20:07 vercel[bot]

IMO Super+K is the wrong keybind for the search bar. It's usually used to access an app's command pallete, which Spacedrive doesn't have yet. Instead I propose two other options:

  • Super+L: Common keybind to access the search bar on web browsers
  • /: Common keybind to access search functions within websites. Works in GitHub, Google, YouTube, Linear and many other sites. I think this is the best one.

Also, I don't think it should be done in Rust. These keybinds are used by many applications, only detecting them when the app is focused is a pretty standard expectation. To go further and hijack them would be irresponsible.

Brendonovich avatar Jul 14 '22 07:07 Brendonovich

IMO Super+K is the wrong keybind for the search bar. It's usually used to access an app's command pallete, which Spacedrive doesn't have yet. Instead I propose two other options:

  • Super+L: Common keybind to access the search bar on web browsers
  • /: Common keybind to access search functions within websites. Works in GitHub, Google, YouTube, Linear and many other sites. I think this is the best one.

Also, I don't think it should be done in Rust. These keybinds are used by many applications, only detecting them when the app is focused is a pretty standard expectation. To go further and hijack them would be irresponsible.

Ok I will happily make these changes if @maxichrome and or @Brendonovich is happy with this proposition. EDIT: Forgive me I meant @jamiepine

RockBacon9922 avatar Jul 14 '22 22:07 RockBacon9922

Happy to merge this, we will however most likely replace this code as soon as a keybind system is in place. Ideally we'd want a universal way to register and override keybinds rather than directly calling document.addEventListener in components.

Edit: Ahh, it looks like the search bar was moved to its own component, which is a merge conflict I can't resolve on GitHub, so in order for this to be merged you'll need to pull main in again and move your code into the SearchBar component.

jamiepine avatar Jul 27 '22 00:07 jamiepine

I'll resolve merge conflicts for this PR and make some necessary changes to the feature's working and should have this mergeable shortly

maxichrome avatar Aug 10 '22 12:08 maxichrome

The way the keyboard shortcut was implemented it would preventing typing "/" anywhere in the app.

I fixed that, updated the keyboard shortcut hint on the search box and also made it so pressing Esc will unfocus the current input anywhere in the app. I also enabled Cmd+A for copy all because that's been bugging me a lot.

oscartbeaumont avatar Aug 30 '22 04:08 oscartbeaumont