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 form token field suggestion list reopening after blurring the input #57002

Merged
merged 4 commits into from
Dec 15, 2023

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Dec 13, 2023

What?

Fixes a regression caused by #56426. Fixes #57085.

That PR accidentally changed the behavior of FormTokenField when __experimentalExpandOnFocus isn't defined, and it should have retained the existing behavior.

It results in the suggestion list unexpectedly reopening after selecting a suggestion and then blurring the input.

How?

I've adjusted the boolean logic that was previously in place to instead use an if statement that should make the code much more readable.

Testing Instructions

Prerequisite: Ensure you already have some post tags defined

  1. Create a new Post
  2. Open the Post sidebar
  3. Start typing the name of one of the tags
  4. Click the suggestion that appears
  5. Now click outside of the field to trigger a blur

In Trunk: The suggestion list closes and then reopens
In this PR: The suggestion list remains closed

Screenshots or screencast

Before

Kapture.2023-12-13.at.12.12.34.mp4

After

Kapture.2023-12-13.at.12.14.38.mp4

@talldan talldan added [Feature] UI Components Impacts or related to the UI component system [Type] Regression Related to a regression in the latest release labels Dec 13, 2023
@talldan talldan self-assigned this Dec 13, 2023
@talldan talldan requested a review from ajitbohra as a code owner December 13, 2023 04:15
@talldan talldan changed the title Fix form token field submit issue Fix form token field suggestion list reopening after blurring the input Dec 13, 2023
Copy link

github-actions bot commented Dec 13, 2023

Flaky tests detected in 344d1c9.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7225832900
📝 Reported issues:

@talldan
Copy link
Contributor Author

talldan commented Dec 13, 2023

It'd be good to add some tests for this, though I'm a little bit lacking into time and not really up-to-speed on the testing for UI components these days.

@mirka mirka requested a review from a team December 15, 2023 10:47
@mirka mirka added the [Package] Components /packages/components label Dec 15, 2023
@fullofcaffeine fullofcaffeine force-pushed the fix/form-token-field-submit-issue branch from 2c4173f to bd82453 Compare December 15, 2023 18:37
Copy link
Contributor

@chad1008 chad1008 left a comment

Choose a reason for hiding this comment

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

This tests well and I agree it's easier to read this way 👍

I also agree tests would be good to add, but we can address them in a follow up so this fix gets in now. 🚀 🚢

@fullofcaffeine fullofcaffeine merged commit e9d5dc4 into trunk Dec 15, 2023
52 checks passed
@fullofcaffeine fullofcaffeine deleted the fix/form-token-field-submit-issue branch December 15, 2023 19:10
@github-actions github-actions bot added this to the Gutenberg 17.4 milestone Dec 15, 2023
fullofcaffeine added a commit that referenced this pull request Dec 15, 2023
…ut (#57002)

* Update boolean logic to ensure suggestions list closes when expandOnFocus prop is false

* Improve readability

* Add Changelog entry

* Fix CHANGELOG, move entry to the "Unreleased" section

---------

Co-authored-by: Marcelo Serpa <[email protected]>
fullofcaffeine added a commit that referenced this pull request Dec 15, 2023
…ut (#57002)

* Update boolean logic to ensure suggestions list closes when expandOnFocus prop is false

* Improve readability

* Add Changelog entry

* Fix CHANGELOG, move entry to the "Unreleased" section

---------

Co-authored-by: Marcelo Serpa <[email protected]>
artemiomorales pushed a commit that referenced this pull request Jan 4, 2024
…ut (#57002)

* Update boolean logic to ensure suggestions list closes when expandOnFocus prop is false

* Improve readability

* Add Changelog entry

* Fix CHANGELOG, move entry to the "Unreleased" section

---------

Co-authored-by: Marcelo Serpa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FormTokenField opens its menu on blur in some cases
4 participants