-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix: DataViews modal actions in list layout #72793
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
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| id: 'secondary', | ||
| label: 'Secondary action', | ||
| callback() {}, | ||
| callback() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the issue: just thought I'd add it so it's easier for us to track this.
jorgefilipecosta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked well on my tests, although we still need to improve the UI on list view.
| > | ||
| { label } | ||
| </Button> | ||
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me why a button with children would prevent the modal from triggering. We need to investigate more the CompositeItem render behavior, though it's good to merge it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WordPress/gutenberg-components this looks like an interesting one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is that you're passing children to both the Composite.Item and the render element's Button.
This behavior is described in https://ariakit.org/guide/composition (emphasis mine):
This also applies to the children prop. You don't need to nest children within the render prop. But if you do, the children passed to the rendered element will override the original component children.
So when you pass children to Button, the content below { isModalOpen && /* ... */ } will be overridden, which is what prevents the modal from appearing.
A fixed version looks something like...
<Composite.Item
/* ... */
render={
<Button /* ... */>
{ label }
{ isModalOpen && ( /* ... */ ) }
</Button>
}
/>(or conversely, shifting all of Button's content to be a children of the Composite.Item)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is potentially something we could lint for, i.e. passing children to both a render prop element and the component itself is likely to produce an unexpected result.
644164d to
5daa7c4
Compare
|
Flaky tests detected in 5daa7c4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18915879597
|
|
There was a conflict while trying to cherry-pick the commit to the wp/6.9 branch. Please resolve the conflict manually and create a PR to the wp/6.9 branch. PRs to wp/6.9 are similar to PRs to trunk, but you should base your PR on the wp/6.9 branch instead of trunk. |
Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
|
Backport at #72804 |
|
There was a conflict while trying to cherry-pick the commit to the wp/6.9 branch. Please resolve the conflict manually and create a PR to the wp/6.9 branch. PRs to wp/6.9 are similar to PRs to trunk, but you should base your PR on the wp/6.9 branch instead of trunk. |
What?
This PR fixes an issue by which modal actions in list layout wouldn't trigger the modal.
How?
Use the
textproperty of the button to render text instead of using children.Testing Instructions
The expectation is that it opens the delete modal.