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

[Autocomplete] Shift+Home when input has focus should not be prevented. #18488

Closed
2 tasks done
chrismcv opened this issue Nov 21, 2019 · 5 comments
Closed
2 tasks done
Labels
component: autocomplete This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists

Comments

@chrismcv
Copy link
Contributor

chrismcv commented Nov 21, 2019

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

I use the Autocomplete, and decide I want to change my value. The cursor is at the end of what I have typed. I want to select all text, and press backspace to clear and start searching again. To make the selection, I use the Shift+Home keyboard shortcut. This does nothing.

Expected Behavior 🤔

Shift+Home should result in all text in the input being selected.

Steps to Reproduce 🕹

Steps:

  1. Use the demo page https://material-ui.com/components/autocomplete/
  2. In first combobox, type "shank"
  3. Decide that you don't want "The Shawshank Redemption"
  4. Press Shift+Home to clear the field.

Context 🔦

The popup menu handling is preventing default on those key events regardless of the modifiers being present.

@oliviertassinari oliviertassinari added the duplicate This issue or pull request already exists label Nov 21, 2019
@oliviertassinari
Copy link
Member

It's a duplicate of #18335

@oliviertassinari
Copy link
Member

The fix is not released yet.

@p00000001
Copy link
Contributor

I am still experiencing this issue on the latest build, and wonder if it is perhaps a misunderstanding of desired behaviour around the Home/End keys.

At present, when the popper is closed, the user can perform common keyboard shortcuts on the text input:

  • Home key to go to the start of the text input
  • End key to go to the end of the text input
  • Shift + Home/End key to select the contents of the text input from the point of the cursor (Windows)

However, once the popper opens, the function of the Home + End key changes to focus on the popper and:

  • Home key goes to the first option in the popper
  • End key goes to the last option in popper

This prevents the user from being able to edit the text input using Home/End without first closing the popper.

Looking at the functionality of other Autocomplete widgets e.g. Google, it seems common that the Home/End keys control the text input field even when the popper is open, to allow the user to adjust the text content.

Perhaps a property on Autocomplete could offer an option between the behaviour of the Home/End keys?

@oliviertassinari
Copy link
Member

@p00000001 Thank you for this detailed report. I completely agree with you. We have an open issue about it #19500. What do you think of my proposed resolution in #19500 (comment)? Do you want to submit a pull request? :)

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label May 3, 2020
@p00000001
Copy link
Contributor

Thanks @oliviertassinari . My apologies that I missed that this was also being discussed in #19500.

I think the handleHomeEndKeys prop sounds ideal. I see that #19887 is also looking to provide an option for fully customised key press handling , but as the Home/End key behaviour on the textbox is mentioned in:

https://www.w3.org/TR/wai-aria-practices-1.1/#listbox-popup-keyboard-interaction

...it would be great to have it as a standard prop option.

I'm only a few weeks into learning React, Javascript, new to GitHub etc. and so there are huge gaps in my knowledge about how to go about implementing an edit on a third party library. However, I've attempted a crash course today and made a pull request #20910. Hopefully it's along the right lines.

Unfortunately it has failed on the API doc update - should I not be editing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants