WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#4196 closed enhancement (fixed)

"Are you sure you want to navigate away from this page?" prompt when not using the RTE

Reported by: johnbillion Owned by: westi
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.1.3
Component: Autosave Keywords: quicktags onbeforeunload reporter-feedback
Focuses: Cc:

Description

When using the RTE, if you make changes to your post and then attempt to navigate away from the page without saving the changes, a nice prompt appears asking for confirmation that you want to navigate away.

The attached patch applies this same confirmation system to the non-RTE editor.

I've added it to wp-includes/js/quicktags.js as I though that was the most logical file to put it in, seeing as it's only for non-RTE editing. If anyone can think of a better place then please holla.

Tested in Fx2 and IE7.

Attachments (5)

4196.diff (1.2 KB) - added by johnbillion 7 years ago.
confirm.png (6.8 KB) - added by johnbillion 7 years ago.
Screenie
4196.my.diff (1.6 KB) - added by rob1n 7 years ago.
4196.2.diff (1.7 KB) - added by johnbillion 7 years ago.
4196.3.diff (1.6 KB) - added by johnbillion 7 years ago.
Patch refreshed, and prompt no longer displayed if content field is empty

Download all attachments as: .zip

Change History (26)

johnbillion7 years ago

comment:1 johnbillion7 years ago

  • Keywords has-patch added

Patchy patchy.

johnbillion7 years ago

Screenie

comment:2 foolswisdom7 years ago

  • Milestone set to 2.3

comment:3 rob1n7 years ago

  • Owner changed from anonymous to rob1n

comment:4 andy7 years ago

What about FF1.5 and IE6?

comment:5 johnbillion7 years ago

Just tested in IE6 on XP and Firefox 1.5 on Vista, both work no problem.

comment:6 rob1n7 years ago

Verified works on Safari 2.0.4, 419.3. I'm downloading the latest nightly of WebKit to test that, too.

comment:7 rob1n7 years ago

Works in WebKit r21081.

comment:8 johnbillion7 years ago

Fails with Opera, but the RTE version of this doesn't work in Opera either as the onbeforeunload event isn't supported in Opera.

comment:9 andy7 years ago

Thanks for testing.

comment:10 rob1n7 years ago

  • Status changed from new to assigned

rob1n7 years ago

johnbillion7 years ago

comment:11 johnbillion7 years ago

rob1n, your new patch doesn't seem to work. On line 402 of wp-includes/js/quicktags.js there is no need for to call confirm as this is handled automatically by the browser.

The onbeforeunload event is a strange one indeed. All you need to pass to it is a string which then gets displayed in a prompt (screenshot). The string is prepended with "Are you sure you want to navigate away from this page?" and appended with "Press OK to continue or Cancel to stay on the current page." This is cross-browser (IE and Fx at least) functionality.

Also, the check for emptiness in the content area needs to use innerText and not innerHTML.

HOWEVER. All that said, I've just noticed a bug in that (with my first patch applied) the prompt appears when you hit one of the submit (Save/Publish, etc) buttons and it shouldn't.

New patch attached.

comment:12 andy7 years ago

Thanks for the good info johnbillion!

comment:13 rob1n7 years ago

  • Status changed from assigned to new

comment:14 Speedboxer7 years ago

The latest patch works in IE7 (up-to-date) and FF 2.0.0.6 (latest) on Windows Vista (Home Premium).

Doesn't work in Opera 9.23 (latest) and Safari 3.0.3 BETA (latest, for Windows).

One thing I noticed is that if you type something in the entry box, and then clear it, you still get the confirm message.

You get no message if the entry box is empty but either (or both) the title and tags boxes are filed. Is this intended/what we want?

johnbillion7 years ago

Patch refreshed, and prompt no longer displayed if content field is empty

comment:15 johnbillion7 years ago

Patch refreshed. Candidate for 2.3?

comment:16 ryan7 years ago

  • Milestone changed from 2.3 to 2.4

comment:17 westi6 years ago

  • Owner changed from rob1n to westi
  • Status changed from new to assigned

comment:18 darkdragon6 years ago

  • Milestone changed from 2.5 to 2.6

No Traction, moving to 2.6, pending testing of the patch with TinyMCE 3.0.x

comment:19 Denis-de-Bernardy5 years ago

  • Component changed from Administration to Autosave
  • Keywords reporter-feedback added; has-patch removed
  • Milestone changed from 2.9 to Future Release

isn't this fixed?

comment:20 azaozz4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Yes, fixed.

comment:21 westi4 years ago

  • Milestone changed from Future Release to 2.9
Note: See TracTickets for help on using tickets.