-
Notifications
You must be signed in to change notification settings - Fork 853
Social: Retain selected preview tab on modal navigation #46886
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
Social: Retain selected preview tab on modal navigation #46886
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes SOCIAL-347 by persisting the selected tab in the unified modal so navigation away from (and back to) Social Preview/Sharing Activity does not reset the user’s last selection.
Changes:
- Refactors
UnifiedModalDatato be screen-specific (sharingActivity.initialTab,socialPreview.initialTab) and updates call sites accordingly. - Updates the unified modal reducer to merge
dataupdates rather than replace the entire object. - Consolidates Sharing Activity tab constants into shared utils and wires Social Preview tab selection into modal data.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/publicize/changelog/update-social-retain-the-preview-tab-on-modal-navigation | Adds changelog entry for the behavior fix. |
| projects/packages/publicize/_inc/utils/constants.ts | Introduces shared SHARING_ACTIVITY_TABS constants. |
| projects/packages/publicize/_inc/social-store/types.ts | Makes UnifiedModalData screen-specific and types sharingActivity.initialTab off the shared constants. |
| projects/packages/publicize/_inc/social-store/reducer/unified-modal.ts | Merges modal data on SET_UNIFIED_MODAL_DATA instead of replacing it. |
| projects/packages/publicize/_inc/hooks/use-schedule-post/index.tsx | Updates unified modal open data shape to sharingActivity.initialTab. |
| projects/packages/publicize/_inc/components/unified-modal/social-post-preview/footer-content.tsx | Updates scheduled-post navigation to set sharingActivity.initialTab via shared constants. |
| projects/packages/publicize/_inc/components/unified-modal/sharing-activity/types.ts | Refactors Sharing Activity filter typing to reference unified modal data (currently introduces a TS type error). |
| projects/packages/publicize/_inc/components/unified-modal/sharing-activity/content.tsx | Reads the Sharing Activity initial tab from getUnifiedModalData().sharingActivity.initialTab. |
| projects/packages/publicize/_inc/components/unified-modal/sharing-activity/constants.ts | Removes now-redundant local tab constants. |
| projects/packages/publicize/_inc/components/unified-modal/sharing-activity/activity-view.tsx | Uses shared tab constants and updates default filter. |
| projects/packages/publicize/_inc/components/customize-and-preview/tab-panels/index.tsx | Persists/restores the selected Social Preview tab via unified modal data. |
| * Filter values for the DataViews. | ||
| */ | ||
| export type SharingActivityFilter = ( typeof TABS )[ keyof typeof TABS ]; | ||
| export type SharingActivityFilter = UnifiedModalData[ 'sharingActivity' ][ 'initialTab' ]; |
Copilot
AI
Feb 2, 2026
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.
SharingActivityFilter is derived via UnifiedModalData['sharingActivity']['initialTab'], but UnifiedModalData['sharingActivity'] is optional (... | undefined). In TypeScript this indexed access will error because undefined has no initialTab property. Consider using NonNullable (and also stripping the optional initialTab to avoid undefined leaking into the filter type) or deriving the union directly from SHARING_ACTIVITY_TABS.
| export type SharingActivityFilter = UnifiedModalData[ 'sharingActivity' ][ 'initialTab' ]; | |
| export type SharingActivityFilter = | |
| NonNullable<NonNullable<UnifiedModalData[ 'sharingActivity' ]>[ 'initialTab' ]>; |
Code Coverage SummaryCoverage changed in 2 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
gmjuhasz
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.
Works well for me, tab is persisted after editing the template.
Fixes SOCIAL-347
Proposed changes:
This PR fixes the issue where navigating away from the Social Preview screen (e.g., to edit a template) and returning would reset the selected tab (Customize/Preview) to the default.
Changes:
Persist selected tab: The preview tab selection is now stored in the unified modal data and restored when returning to the screen
Screen-specific modal data: Refactored
UnifiedModalDatato be screen-specific:sharingActivity.initialTab- for the Sharing Activity screen tabssocialPreview.initialTab- for the Social Preview screen tabs (Customize/Preview)Merge modal data on update: Updated the reducer to merge data instead of replacing it, so setting data for one screen doesn't erase data for another
Consolidate constants: Moved
SHARING_ACTIVITY_TABSfrom a component-specific constants file to shared utils for better reusabilityOther information:
Jetpack product discussion
SOCIAL-347
Does this pull request change what data or activity we track or use?
No changes to data tracking.
Testing instructions:
Screen.Recording.2026-02-02.at.12.59.58.PM.mov
Screen.Recording.2026-02-02.at.1.00.59.PM.mov