Make WordPress Core

Opened 10 years ago

Closed 2 years ago

Last modified 2 years ago

#40493 closed enhancement (fixed)

On the Edit User Profile page, prevent losing data when clicking links

Reported by: ashokrane Owned by: joedolson
Priority: normal Milestone: 6.6
Component: Users Version:
Severity: normal Keywords: target-blank has-patch commit
Cc: Focuses: accessibility, javascript

Description

On the Edit User Profile, open the "You can change your profile picture on Gravatar." link in a new window.
Reason being that otherwise it causes the user to loose any data that they have edited in the form, but not yet saved.

Attachments (5)

40493.diff​ (1.3 KB ) - added by karlijnbk 6 years ago.
40493.2.diff​ (1.1 KB ) - added by jwgoedert 3 years ago.
updated 40493 diff file
40493warning.png​ (266.7 KB ) - added by jwgoedert 3 years ago.
40493 Warning after edits and redirect
40493.3.diff​ (1.2 KB ) - added by joedolson 2 years ago.
Minor formatting tweaks
40493.4.diff​ (556 bytes ) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (24)

#1 @swissspidy
10 years ago

  • Keywords target-blank added

Hey there,

Thanks for your report and welcome!

As per #23432, we rather strive to remove usage of target="_blank". As for losing data, the browser should warn you when you're about to leave a page without having saved the form.

See https://core.trac.wordpress.org/query?keywords=~target-blank for related tickets.

#2 @ashokrane
10 years ago

Thanks @swissspidy. I agree. The browser didn't throw any warning when I have unsaved data & when I clicked on the "Gravatar" text. Doing that would be a better approach then opening in a new window (after going through other related tickets).

#3 @ajmaurya
9 years ago

  • Keywords reporter-feedback added

Hey i also once had the same thought on opening the Gravatar link in a new window, but after reading this it totally makes much more sense now.

#4 @afercia
8 years ago

  • Focuses accessibility added

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


8 years ago

#6 @afercia
8 years ago

  • Keywords needs-patch added; reporter-feedback removed
  • Milestone Awaiting Review → Future Release
  • Version 4.7.3

Discussed during today's accessibility bug-scrub, agreed this form would need the JS confirm to warn users they can lose data when navigating away. No target _blank please :)

#7 @karlijnbk
6 years ago

Regarding the patch above, please also give props to @diedeexterkate.

The patch above fixes the issue on the user edit pages and "add new user" page. We tested this on Chrome, Edge, Firefox and Safari on macOS.
Important to note that in Safari this does not work. We think this is due to back-forward caching (see ​https://stackoverflow.com/questions/40938707/safari-onbeforeunload/41769343).

#8 @Mista-Flo
6 years ago

  • Keywords has-patch added; needs-patch removed

#9 @sabernhardt
4 years ago

  • Focuses javascript added
  • Keywords needs-refresh added
  • Summary On the Edit User Profile, open the "You can change your profile picture on Gravatar." link in a new window → On the Edit User Profile page, prevent losing data when clicking links

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


3 years ago

#11 @joedolson
3 years ago

  • Milestone Future Release → 6.6
  • Owner set to joedolson
  • Status new → accepted

Looking at this for 6.6, and as a requirement to resolve #60100.

This ticket was mentioned in ​PR #6424 on ​WordPress/wordpress-develop by ​jwgoedert.


3 years ago
#12

  • Keywords needs-refresh removed

Verified @karlijnbk patch:

Added isSubmitting boolean, and form variables for tracking changes
Added initial form check.
Added conditional in 'beforeunload' check to handle redirects and present 'Changes that you made may not be saved.' warning message.

Trac ticket:
https://core.trac.wordpress.org/ticket/40493

@jwgoedert
3 years ago

updated 40493 diff file

@jwgoedert
3 years ago

40493 Warning after edits and redirect

#13 @jwgoedert
3 years ago

Submitted PR and included screenshots(accidentally added two, need to remove one...)
Verification of patch and efforts from work of @karlijnbk @diedeexterkate

New Diff attached and PR link below.

​https://github.com/WordPress/wordpress-develop/pull/6424

@joedolson
2 years ago

Minor formatting tweaks

#14 @joedolson
2 years ago

  • Keywords commit added

This looks good. Other than a couple of minor formatting tweaks, I think it's good to go.

#15 @joedolson
2 years ago

  • Resolution → fixed
  • Status accepted → closed

In 58137:

Users: Add JS confirmation if user profile has unsaved changes.

Add a confirmation dialog when users navigate away from the user profile screen if they have unsaved changes to prevent data loss.

Props ashokrane, karlijnbk, diedeexterkate, jwgoedert, joedolson, swissspidy, afercia.
Fixes #40493.

#16 @SergeyBiryukov
2 years ago

  • Resolution fixed
  • Status closed → reopened

Thanks for the commit!

A similar string is already used elsewhere:

The changes you made will be lost if you navigate away from this page.

Could we reuse it here instead of introducing a new one?

​@SergeyBiryukov commented on ​PR #6424:


2 years ago
#17

Thanks for the PR! This was merged in r58137.

#18 @SergeyBiryukov
2 years ago

  • Resolution → fixed
  • Status reopened → closed

In 58145:

Users: Reuse an existing string in the confirmation for unsaved changes in user profile.

Follow-up to [58137].

Fixes #40493.

#19 @joedolson
2 years ago

Thanks, @SergeyBiryukov!

Note: See TracTickets for help on using tickets.