Skip to content

Conversation

@juanfra
Copy link
Member

@juanfra juanfra commented Oct 22, 2025

What?

Closes #72522

We're updating the ComboboxControl, so that it shows the reset button only if there's a value. The reset button should only appear when there's an actual value to clear, and be hidden when the combobox is empty.

Why?

To improve UX. Removing unnecessary and confusing UI elements when there's nothing to clear.

Testing Instructions

  1. Checkout this PR.
  2. Run nvm use && npm run storybook:dev
  3. Visit the ComboboxControl story ?path=/docs/components-comboboxcontrol--docs
  4. Confirm the reset button is only displayed if there's a value selected.

Screenshots or screencast

combobox-reset-with-value.mp4

@juanfra juanfra requested a review from ajitbohra as a code owner October 22, 2025 15:15
@juanfra juanfra added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Oct 22, 2025
@github-actions
Copy link

github-actions bot commented Oct 22, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

Flaky tests detected in 1657aa3.
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/18801032211
📝 Reported issues:

@juanfra juanfra requested a review from a team October 23, 2025 15:03
Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Nice enhancement, thanks!

  1. I just noticed the Storybook has allowReset: false set, which is strange because it isn't the default setting. Let's take this opportunity to remove that.

  2. If it isn't too much extra work, can we also hide the button in this case too, where there is technically a value set but it isn't visible? (Not a blocker to merging though — the changes in this PR are already an improvement over trunk.)

    CleanShot.2025-10-24.at.16-46-43.mp4

Comment on lines 359 to 364
it( 'should render with Reset button disabled', () => {
render(
<Component
options={ timezones }
label={ defaultLabelText }
value={ timezones[ 0 ].value }
Copy link
Member

Choose a reason for hiding this comment

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

Is this test outdated now? The reset button is never going to be disabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. Good catch.

<Component
options={ timezones }
label={ defaultLabelText }
value={ targetOption.value }
Copy link
Member

Choose a reason for hiding this comment

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

Setting a value prop like this is not going to be very realistic in the tests for uncontrolled mode, because the static value will basically force an internal value even after a reset.

It would be better not set a value from the prop, but instead simulate the user picking a value (which we're already doing in this test here).

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfect, will update this one.

await user.click( resetButton );

expect( input ).toHaveValue( '' );
expect( resetButton ).toBeDisabled();
Copy link
Member

Choose a reason for hiding this comment

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

Can we still test for not.toBeInTheDocument?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure 🫡

@juanfra
Copy link
Member Author

juanfra commented Oct 25, 2025

Thank you for the review @mirka :) I’ve addressed the feedback.

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 🚀

@mirka mirka merged commit 4087546 into trunk Oct 27, 2025
35 checks passed
@mirka mirka deleted the fix/72522-combobox-reset-when-value branch October 27, 2025 15:35
@github-actions github-actions bot added this to the Gutenberg 22.0 milestone Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ComboboxControl reset button should be displayed if there's a value

3 participants