Forms: Add item click handler for DataViews on dashboards#46752
Forms: Add item click handler for DataViews on dashboards#46752
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Pull request overview
This PR adds onClickItem handlers to the Forms dashboards to restore item selection functionality that was removed in DataViews 11.2.0. The handlers ensure clicking on an item in the responses or inbox dashboards selects that item exclusively.
Changes:
- Added
onClickItemcallback to both inbox and responses dashboards that sets the clicked item as the only selected item - Updated TypeScript casting in the responses stage component
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| projects/packages/forms/src/dashboard/inbox/stage/index.js | Adds onClickItem handler to select items when clicked in inbox dashboard |
| projects/packages/forms/routes/responses/stage.tsx | Adds onClickItem handler for responses dashboard and updates type casting |
| projects/packages/forms/changelog/update-forms-click-item | Changelog entry for the new feature |
| Significance: patch | ||
| Type: added | ||
|
|
||
| Forms: Add item click handler for DataViews on dashboards |
There was a problem hiding this comment.
The changelog entry should end with a period according to the project's changelog guidelines. The entry should read: "Add item click handler for DataViews on dashboards."
| const onClickItem = useCallback( | ||
| item => { | ||
| onChangeSelection( [ item.id.toString() ] ); | ||
| }, | ||
| [ onChangeSelection ] | ||
| ); |
There was a problem hiding this comment.
The onClickItem callback is missing analytics tracking that exists in the desktopViewAction (lines 522-525). Since this new handler serves a similar purpose of selecting an item for viewing, consider adding analytics tracking using jetpackAnalytics.tracks.recordEvent to maintain consistency with the existing 'view-response' action tracking. This would help maintain visibility into how users interact with items in the dashboard.
| const navigate = useNavigate(); | ||
| const counts = useSelect( | ||
| select => ( select( dashboardStore ) as SelectActions ).getCounts(), | ||
| select => ( select( dashboardStore ) as unknown as SelectActions ).getCounts(), |
There was a problem hiding this comment.
This casting change from as SelectActions to as unknown as SelectActions appears unrelated to the PR's stated purpose of adding an item click handler for DataViews. If this change addresses a TypeScript error, it should be explained in the PR description or handled in a separate commit. If it's unrelated to the DataViews 11.2 update, consider removing it from this PR to maintain focus on the primary change.
| select => ( select( dashboardStore ) as unknown as SelectActions ).getCounts(), | |
| select => ( select( dashboardStore ) as SelectActions ).getCounts(), |
Code Coverage SummaryCoverage changed in 1 file.
|
3a80b2b to
eea6732
Compare


Fixes FORMS-459
Proposed changes:
Uses the
onClickItemprop to handle item selection, given that the current click behavior was removed on DataViews 11.2This does not match exactly the current implementation, and that is deliberate to better match the UI. Clicking on an item will always set this item as the only selected item.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
To see this after the change in DataViews, checkout #46430 and apply this PR's changes on top of it, but this is optional.
This does not apply for the forms dashboard, as there is no "View" action there at this point.