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(components): [select] abnormal focus when click tags #13699

Merged
merged 6 commits into from
Aug 3, 2023
Merged

Conversation

tolking
Copy link
Member

@tolking tolking commented Jul 22, 2023

closed #13665, close #13487, close #13750

before

after

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

Description

🤖 Generated by Copilot at 9e3e21f

This pull request enhances the accessibility and keyboard interaction of the select component and its multiple variant. It adds or modifies some attributes and methods related to focus and role in select.vue and useSelect.ts. It also fixes some bugs and refactors some code in these files.

Related Issue

Fixes #___.

Explanation of Changes

🤖 Generated by Copilot at 9e3e21f

  • Improve the accessibility and keyboard interaction of the multiple select component by adding role, tabindex, and click attributes and handler to the tags element (link)
  • Remove the unused import of useFocus from select.vue (link)
  • Add the focus method to the methods object and the expose function of the select.vue component, which is a proxy for the focus method defined in useSelect.ts (link, link)
  • Remove the redundant or unnecessary focus methods from the setup function and the expose function of the select.vue component (link, link)
  • Add the focused state to the useSelectStates function in useSelect.ts, which indicates whether the select component is focused or not (link)
  • Remove the line that blurs the input element in the resetInputState function in useSelect.ts, which causes the select component to lose focus when cleared or closed (link)
  • Add the call to the focus method in the handleClear function in useSelect.ts, which ensures that the select component remains focused after clearing (link)
  • Replace the ignoreFocusEvent variable with the focused state in the handleFocus function in useSelect.ts, which is a more robust way to track the focus status and avoid unnecessary events (link)
  • Set the focused state to true in the handleFocus function in useSelect.ts, which updates the state accordingly when the select component is focused (link)
  • Modify the handleBlur function in useSelect.ts to check for the tagTooltipRef value and set the focused state to false, which improves the focus management and accessibility and prevents the blur event from being emitted when the user focuses on the tooltip content or the select component itself (link)
  • Simplify the call to the focus method in the handleComposition function in useSelect.ts, which makes the code more concise and consistent (link)
  • Add the focus method to the return value of the useSelect function in useSelect.ts, which exposes the method to the select.vue component (link)

@github-actions
Copy link

github-actions bot commented Jul 22, 2023

@github-actions github-actions bot added the CommitMessage::Qualified Qualified commit message label Jul 22, 2023
@github-actions
Copy link

github-actions bot commented Jul 22, 2023

🧪 Playground Preview: https://element-plus.run/?pr=13699
Please comment the example via this playground if needed.

@tolking tolking changed the title fix(components): [select] abnormal focus when click tags WIP: fix(components): [select] abnormal focus when click tags Jul 22, 2023
@tolking tolking changed the title WIP: fix(components): [select] abnormal focus when click tags fix(components): [select] abnormal focus when click tags Jul 22, 2023
@hahatulk
Copy link

thanks for fix! please approve it, very annoying bug

@tolking tolking requested a review from a team July 28, 2023 00:58
Copy link
Collaborator

@btea btea left a comment

Choose a reason for hiding this comment

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

Maybe we can add a test case?

@btea btea merged commit 0109ab6 into dev Aug 3, 2023
10 checks passed
@btea btea deleted the fix/select-tag-blur branch August 3, 2023 12:15
@element-bot element-bot mentioned this pull request Aug 4, 2023
3 tasks
consultation-applio pushed a commit to consultation-applio/element-plus that referenced this pull request Nov 10, 2023
…s#13699)

* fix(components): [select] abnormal focus when click tags

closed element-plus#13665

* fix(components): [select] clearable

* chore(components): [select] remove console

* fix: the setTimeout function may bring some side effects

* fix: remove role

* test(components): [select] add some test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment