-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataViews: Avoid double click handler on primary fields #67393
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. |
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.
LGTM!
Should we add a comment that explains why event.preventDefault() and event.stopPropagation() are necessary?
Flaky tests detected in 59708ba. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12072670743
|
onKeyDown: ( event: React.KeyboardEvent ) => { | ||
if ( event.key === 'Enter' || event.key === '' ) { | ||
event.preventDefault(); | ||
event.stopPropagation(); |
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.
These calls should be in the onClickItem
handler. If the dataview doesn't specify any onClickItem
handler, the default one does nothing and you want the event to bubble up.
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 there's actually a few more issues where the classnames, role... shouldn't be added if there's no onClickItem. I'll open a follow-up.
) Co-authored-by: youknowriad <[email protected]> Co-authored-by: gigitux <[email protected]>
Co-authored-by: youknowriad <[email protected]> Co-authored-by: gigitux <[email protected]>
Follow up to #67199
What?
That PR highlighted a hidden bug in DataViews where clicking primary fields triggered both "onClick" handler and "onSelectionChange". This PR prevents that by stopping the propagation of the event.
Testing Instructions
1- Open the "pages" page in the site editor.
2- Switch to table view.
3- Click on the "title" of a page.
4- You should navigate to the editor.