Polaris-react: [Autocomplete][v1] the enter keystroke event should not bubble up

Created on 29 Apr 2019  路  2Comments  路  Source: Shopify/polaris-react

Issue summary

When using the keyboard to select an option; pressing enter will trigger the parent form's onSubmit. I think we should call stopPropagation() of the event so it does not bubble up to the form.

Expected behavior

Select the option and don't trigger the for submission.

Actual behavior

Select the option and trigger the for submission.

Steps to reproduce the problem

  1. Click on the field
  2. Navigate with your keyboard
  3. Press enter

Reduced test case

See https://codesandbox.io/s/oqmom5qrxz

Specifications

  • Are you using the React components? (Y/N): yes
  • Polaris version number: 3.13
  • Browser: Chrome
  • Device: Mac Book Pro
  • Operating System: Mac OS
馃専 Autocomplete 馃悰Bug

Most helpful comment

Just for context, in case it's helpful, I had to do something similar in my codebase. I had to modify KeypressListener to listen to keydown event in case of Enter, because that's what triggers form submit, it's too late to stopPropagation() on keyup.

All 2 comments

Just for context, in case it's helpful, I had to do something similar in my codebase. I had to modify KeypressListener to listen to keydown event in case of Enter, because that's what triggers form submit, it's too late to stopPropagation() on keyup.

Autocomplete is currently being reworked as a part of the AutoComplete component project. Once we address this problem in the reworked component, we鈥檒l close this issue.

Was this page helpful?
0 / 5 - 0 ratings