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

Add children back to toolbar item render for rendered components #53314

Merged
merged 5 commits into from
Sep 12, 2023

Conversation

joshuatf
Copy link
Contributor

@joshuatf joshuatf commented Aug 3, 2023

What?

Fixes #53313
Allows usage of children for toolbar item components that make use of the as prop.

Why?

This was removed in #51623. I believe this was unintentional and missed as a test case since many of the ToolbarItems take advantage of icon or label props, but pinging @diegohaz to confirm that there are no other issues with doing this with the newer Ariakit implementation.

How?

This PR simply reverts to passing children to BaseToolbarItem so they can be used by the passed component in render.

Testing Instructions

  1. Add a component that uses both the as property and children:
<ToolbarItem
	as={ Button }
	variant="primary"
	onClick={ doSomething }
>
	This text should show
</ToolbarItem>
  1. Verify that the text is shown in the toolbar button
  2. Check other toolbar items around the site to make sure no regressions have occurred

Optionally, to see a real-world use case where this was broken:

  1. Install WooCommerce 8.0 RC-1 - https://github.com/woocommerce/woocommerce/releases/tag/8.0.0-rc.1
  2. Use the latest GB and/or WP 6.3.
  3. Enable the new product editing experience under WooCommerce -> Settings -> Advanced -> Features.
  4. Navigate to the Add Product page.
  5. Click on "Add description"
  6. Note that the "Cancel" and "Done" buttons and text are visible in the modal toolbar.

Testing Instructions for Keyboard

Screenshots or screencast

Before

Screen Shot 2023-08-03 at 1 47 39 PM

After

Screen Shot 2023-08-03 at 1 50 01 PM

@joshuatf joshuatf self-assigned this Aug 3, 2023
@alexstine alexstine added the [Type] Regression Related to a regression in the latest release label Aug 3, 2023
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Thanks for diagnosing it and working to address it @joshuatf 🙌

I agree with @diegohaz that it feels best to actually pass children to the Component instance of the render prop, either the way Diego suggested, or as a children prop to the Component instance.

@alexstine alexstine removed their request for review August 30, 2023 16:36
@ciampo ciampo added the [Package] Components /packages/components label Sep 7, 2023
@ciampo
Copy link
Contributor

ciampo commented Sep 7, 2023

Hey @joshuatf , just checking if you have the capacity to wrap up this PR :)

@ciampo
Copy link
Contributor

ciampo commented Sep 12, 2023

Hey @tyxla and @diegohaz , would you mind giving this PR one last look? I took over, rebased, and addressed feedback.

Thank you!

@ciampo
Copy link
Contributor

ciampo commented Sep 12, 2023

For some some prettier wasn't working properly on my machine — that should be fixed now.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ciampo ciampo enabled auto-merge (squash) September 12, 2023 10:35
@ciampo ciampo merged commit cc3512d into trunk Sep 12, 2023
49 of 50 checks passed
@ciampo ciampo deleted the fix/53313 branch September 12, 2023 10:59
@github-actions github-actions bot added this to the Gutenberg 16.7 milestone Sep 12, 2023
@github-actions
Copy link

Flaky tests detected in c741395.
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/6158166746
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[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.

Toolbar items using a component and children do not render children
5 participants