Make WordPress Core

Opened 3 months ago

Last modified 3 weeks ago

#64623 accepted defect (bug)

Prevent losing data when clicking links on Settings pages

Reported by: sabernhardt's profile sabernhardt Owned by: joedolson's profile joedolson
Milestone: 7.1 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch changes-requested has-unit-tests
Focuses: accessibility, javascript Cc:

Description

Reported by @vidugupta on #23432 and PR 9130

Several external links within WordPress admin setting pages—specifically General, Discussion, and Permalink—currently open in the same window. This behavior can negatively impact the user experience in the following ways:

  • Users may lose unsaved changes if they click an external link without first saving their settings.
  • Users may assume the link opens in a new tab (as is the case with links in the Edit Profile page or the Help tab), and unintentionally navigate away from the page.

Inconsistencies in link behavior across admin pages create confusion and a fragmented user experience.

Change History (11)

#1 @sabernhardt
3 months ago

#40493 added a JS confirmation before navigating away from the profile page, and that could be appropriate for Settings pages too.

#2 @joedolson
3 months ago

  • Milestone changed from Awaiting Review to 7.0
  • Owner set to joedolson
  • Status changed from new to accepted

#3 @westonruter
3 months ago

Aside: if bfcache were enabled in the admin, then navigating away from an unsaved settings screen would not mean the loss of unsaved settings. See #63636. That said, browsers typically persist changes to plain form fields when navigating away and back again. Controls built with JS, however, get re-built and there is data loss.

#4 @joedolson
3 months ago

I think that it's important to give users a confirmation. Even if those unsaved settings were persistent, the notice ensures that the user is either deciding not to save their changes or reminding them to save their changes. When it's a silent behavior, the user can think that they've already saved and never come back.

Last edited 3 months ago by joedolson (previous) (diff)

This ticket was mentioned in PR #10927 on WordPress/wordpress-develop by @anukasha.


3 months ago
#5

  • Keywords has-patch added

Trac ticket: [](https://core.trac.wordpress.org/ticket/64623)

## Use of AI Tools

@westonruter commented on PR #10940:


3 months ago
#7

Thank you for the PR, but this isn't the right approach. The alert needs to only be shown when there are unsaved changes, and it needs to show when navigating away from an admin screen by any means (including the use of the back button). Please offer suggestions to the existing PR: https://github.com/WordPress/wordpress-develop/pull/10927

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


2 months ago

#9 @sabernhardt
7 weeks ago

  • Keywords changes-requested added
  • Milestone changed from 7.0 to 7.1

The patch (PR 10927) still needs changes, so I will move this ticket to the next release cycle.

This ticket was mentioned in PR #9130 on WordPress/wordpress-develop by @vidugupta.


3 weeks ago
#10

  • Keywords has-unit-tests added

Problem:
Several external links on WordPress admin Settings pages—specifically General, Discussion, and Permalink—currently open in the same window. This creates multiple user experience issues:

Users may lose unsaved changes if they click an external link without saving.
Users may expect links to open in a new tab (like Edit Profile or Help links) and unintentionally navigate away.
Inconsistent link behavior across admin pages causes confusion and a fragmented interface.

Root Cause:
Some documentation/help links in the Settings pages lack target="_blank", making the UI inconsistent and unpredictable.

Solution:
Update affected external documentation/help links to include target="_blank", so they open in a new tab.
Add visual and screen-reader indicators for new-tab links to improve accessibility:

  • External link icon (Dashicons)
  • aria-label text for screen readers
  • Keep internal admin links navigating between Settings pages in the same tab, and add a JS warning for unsaved changes to prevent data loss.

Benefits:

  • Prevents accidental data loss on Settings pages.
  • Ensures consistent and predictable link behavior.
  • Improves accessibility and UX for all users.

Trac Ticket (New/Main): #64623

Related Ticket (Old): #23432

@anukasha commented on PR #10927:


3 weeks ago
#11

I'm not opposed to adding a new JS file that contains JS for options screens, but if so, I think we should be moving all the existing JS into it, as well. Currently, options.php contains a ton of admin_head hooked functions that print JS for the various pages, and we instead handle those differently in a central file.

@joedolson I agree with your point. I have created a new ticket for moving all existing js to options.js - https://core.trac.wordpress.org/ticket/65070
Current ticket will simply introduce the options.js file and is scoped to the unsaved changes feature for now.

Note: See TracTickets for help on using tickets.