Skip to content

Improve delete site focus tab and selected site id - #2480

Closed
sejas wants to merge 5 commits into
trunkfrom
update/stu-1241-when-deleting-site-focus-always-moves-to-the-first-site
Closed

Improve delete site focus tab and selected site id#2480
sejas wants to merge 5 commits into
trunkfrom
update/stu-1241-when-deleting-site-focus-always-moves-to-the-first-site

Conversation

@sejas

@sejas sejas commented Jan 26, 2026

Copy link
Copy Markdown
Member

Related issues

Proposed Changes

  • Fix delete site behaviour but keep the logic simple

Testing Instructions

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
gcsecsey and others added 5 commits January 23, 2026 16:11
- Update the logic to reset the selected tab to 'overview' only if the currently selected site no longer exists and a selection change has occurred.
- Improve clarity in comments regarding selection changes and tab resets.
@sejas sejas changed the title Update/stu 1241 when deleting site focus always moves to the first site Jan 26, 2026
@sejas sejas self-assigned this Jan 26, 2026
@sejas
sejas requested a review from gcsecsey January 26, 2026 20:01
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 86a88f2 vs trunk

site-editor

Metric trunk 86a88f2 Diff Change
load 2912.00 ms 2895.00 ms -17.00 ms 🟢 -0.6%

site-startup

Metric trunk 86a88f2 Diff Change
siteCreation 7076.00 ms 7077.00 ms +1.00 ms 🔴 0.0%
siteStartup 3927.00 ms 3941.00 ms +14.00 ms 🔴 0.4%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@gcsecsey gcsecsey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggesting this approach @sejas! I experimented with this approach earlier as well, and I found that it doesn't always work as expected when following these steps:

  1. Delete a site
  2. Don't switch site, but optionally switch tabs
  3. Observe that the selected site is updated to the first site, but the selected tab isn't updated to "Overview"
CleanShot.2026-01-27.at.09.49.36.mp4

I think this might be caused by the selectedSiteId being set from the SITE_EVENTS.DELETED event listener, and the tab state update being prevented from running.

@sejas sejas closed this Jan 27, 2026
@sejas sejas reopened this Jan 27, 2026
@sejas

sejas commented Jan 27, 2026

Copy link
Copy Markdown
Member Author

@gcsecsey, thanks for reviewing the PR. I tested it again and I'm not able to reproduce your issue.

delete-site-switch-to-overview-or-keep-navigation.mp4
@gcsecsey

gcsecsey commented Jan 27, 2026

Copy link
Copy Markdown
Member

Thanks for huddling about these PRs @sejas! I tested these changes on Windows x64 too because I was suspicious that something's off with my environment on Mac. I see the same issue when deleting a site, and staying on the same site:

CleanShot.2026-01-27.at.11.28.32.mp4

As we discussed on the huddle, it might be worth looking into unifying the deletion logic across SITE_EVENTS.DELETED listener and the onDeleteSite handler. As both of these call setSelectedSiteId, there might be a race condition on the state updates.

@sejas

sejas commented Jan 27, 2026

Copy link
Copy Markdown
Member Author

Thank you @gcsecsey , let's go with your approach!

@sejas sejas closed this Jan 27, 2026
@sejas
sejas deleted the update/stu-1241-when-deleting-site-focus-always-moves-to-the-first-site branch January 27, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants