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(input): only focus the first input / textarea when clicking on the parent item #22049

Merged
merged 5 commits into from
Sep 14, 2020

Conversation

brandyscarney
Copy link
Member

@brandyscarney brandyscarney commented Sep 8, 2020

⚠️ dev build: 5.4.0-dev.202009081606.5ddd37f ⚠️

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: fixes #22037 resolves #22032

What is the new behavior?

  • Check if the event target is an ion-item before focusing the first input, thus if another input exists it won't change focus
  • Add support for focusing ion-textarea if that exists as the first input

Does this introduce a breaking change?

  • Yes
  • No

Other information

@ionitron-bot ionitron-bot bot added the package: core @ionic/core package label Sep 8, 2020
@brandyscarney
Copy link
Member Author

brandyscarney commented Sep 10, 2020

Open the test at /src/components/item/test/inputs in Chrome

  1. If you clicked on something after opening, refresh so nothing has focus
  2. Click on the label “Multiple inputs” — see that the first input “Input 1" has focus
  3. Click on “Input 2” — see that it has focus
  4. Click on the label “Multiple inputs” again - see that the second input remains focused

Repeat in Safari, except on step 4 it will focus the first input again. This is due to Safari changing the activeElement to the first input when you click the item label, even though it doesn't change the focus. Do we revert back to where they both behave the same? cc @liamdebeasi

I thought about this some more - and I think we should do whatever iOS 14 is doing where delegatesFocus is working.

@liamdebeasi
Copy link
Contributor

Agreed re: following iOS 14 behavior on iOS.

Also, this fix should also account for other focusable elements too not just ion-input and ion-textarea. For example, if you have an input and a button, clicking the button would cause the input to be focused which is not always correct. See: #21982 It seems to be the same issue where you click the second input, but the first input gets focused.

@brandyscarney brandyscarney added this to the 5.3.3 milestone Sep 11, 2020
@brandyscarney brandyscarney merged commit 99f2532 into master Sep 14, 2020
@brandyscarney brandyscarney deleted the fix-input-focus-multiple branch September 14, 2020 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
2 participants