Skip to content

Conversation

@manzoorwanijk
Copy link
Member

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:

  1. Persist selected tab: The preview tab selection is now stored in the unified modal data and restored when returning to the screen

  2. Screen-specific modal data: Refactored UnifiedModalData to be screen-specific:

    • sharingActivity.initialTab - for the Sharing Activity screen tabs
    • socialPreview.initialTab - for the Social Preview screen tabs (Customize/Preview)
  3. 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

  4. Consolidate constants: Moved SHARING_ACTIVITY_TABS from a component-specific constants file to shared utils for better reusability

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

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:

  • Create or edit a post with Jetpack Social connections configured
  • Open the Social preview modal
  • Select a connection other than the first one
  • Set the media to use template
  • Click on "Edit template"
  • Navigate back to the preview screen
  • Verify: The connection tab should still be selected (not reset to the first connection)
BEFORE AFTER
Screen.Recording.2026-02-02.at.12.59.58.PM.mov
Screen.Recording.2026-02-02.at.1.00.59.PM.mov

@manzoorwanijk manzoorwanijk requested a review from a team February 2, 2026 07:40
@manzoorwanijk manzoorwanijk self-assigned this Feb 2, 2026
Copilot AI review requested due to automatic review settings February 2, 2026 07:40
@manzoorwanijk manzoorwanijk added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the update/social/retain-the-preview-tab-on-modal-navigation branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/social/retain-the-preview-tab-on-modal-navigation

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Publicize Now Jetpack Social, auto-sharing [Package] Publicize labels Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Copy link
Contributor

Copilot AI left a 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 UnifiedModalData to be screen-specific (sharingActivity.initialTab, socialPreview.initialTab) and updates call sites accordingly.
  • Updates the unified modal reducer to merge data updates 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' ];
Copy link

Copilot AI Feb 2, 2026

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.

Suggested change
export type SharingActivityFilter = UnifiedModalData[ 'sharingActivity' ][ 'initialTab' ];
export type SharingActivityFilter =
NonNullable<NonNullable<UnifiedModalData[ 'sharingActivity' ]>[ 'initialTab' ]>;

Copilot uses AI. Check for mistakes.
@jp-launch-control
Copy link

jp-launch-control bot commented Feb 2, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/publicize/_inc/components/customize-and-preview/tab-panels/index.tsx 0/10 (0.00%) 0.00% 5 💔
projects/packages/publicize/_inc/utils/constants.ts 2/2 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Copy link
Contributor

@gmjuhasz gmjuhasz left a 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.

CleanShot.2026-02-02.at.10.38.40.mp4

@manzoorwanijk manzoorwanijk merged commit 0000326 into trunk Feb 2, 2026
72 of 73 checks passed
@manzoorwanijk manzoorwanijk deleted the update/social/retain-the-preview-tab-on-modal-navigation branch February 2, 2026 09:46
@github-actions github-actions bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Publicize Now Jetpack Social, auto-sharing [Package] Publicize [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants