Skip to content

feat(search): clear and unfocus input on esc keypress#2423

Open
Cassolette wants to merge 3 commits intoopencloud-eu:mainfrom
Cassolette:patch/searchbar-esc-clear
Open

feat(search): clear and unfocus input on esc keypress#2423
Cassolette wants to merge 3 commits intoopencloud-eu:mainfrom
Cassolette:patch/searchbar-esc-clear

Conversation

@Cassolette
Copy link
Copy Markdown
Contributor

Description

Currently there is no straightforward way to clear the search input. Users have to use traditional means to do so (i.e. select all the text and delete them) which can make file finding by multiple attempts a little troublesome.

To improve search productivity while using keyboard controls, a shortcut keybinding via Esc is introduced to the search bar. While in focus, any search term is cleared when Esc is pressed. Otherwise if there's no search term, the focus on the text input will be rescinded to restore regular operations.

This behaviour is being referenced from GitHub's file finder. OneDrive also has an esc key binding that clears the search input.

Related Issue

  • Fixes <issue_link>

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

Comment on lines +521 to +522
const inputElement = this.$el.getElementsByTagName('input')[0] as HTMLElement
inputElement.blur()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather remove the blur and only keep clearing the term. It feels a bit weird to reset the focus on an input on esc. The blur works for GitHub because the search expands into this "overlay", which we don't have.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh no not that search button.. guess I should've been clearer. My reference point on esc unfocusing an input came from GDrive and this repo file finder:

img

I'll remove the blur later 🙂

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.

2 participants