Last modified: 2014-09-23 23:53:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32101, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30101 - Vector: "Stay on page" EditWarning ignored when pressing "Enter" in search box
Vector: "Stay on page" EditWarning ignored when pressing "Enter" in search box
Status: NEW
Product: MediaWiki skins
Classification: Unclassified
Vector (Other open bugs)
unspecified
All All
: Low normal
: ---
Assigned To: Rob Moen
:
Depends on:
Blocks: 44881
  Show dependency treegraph
 
Reported: 2011-07-28 18:01 UTC by Dan Barrett
Modified: 2014-09-23 23:53 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Proposed patch (1.66 KB, patch)
2011-07-30 07:22 UTC, Michael M.
Details
Proposed patch - part 2 (819 bytes, patch)
2011-08-04 07:52 UTC, Michael M.
Details

Description Dan Barrett 2011-07-28 18:01:13 UTC
The "edit warning" feature of the Vector skin does not pop up a warning when the user uses the SimpleSearch box.  Use case:

1. Edit any article.
2. Make a change in the edit box but do not save.
3. (Optional) Click the "History" link: confirm that you get a proper edit warning. Cancel it.
4. Remaining on the edit page, type text into the search box and press Enter.
5. You leave the edit page without a warning, even though the text is modified.

You have now lost your unsaved work.
Comment 1 Brion Vibber 2011-07-28 23:23:56 UTC
By "edit warning" do you mean the confirmation dialog for navigating away from the page?
Comment 2 Dan Barrett 2011-07-28 23:27:00 UTC
Yes, that's right. I used the phrase "edit warning" because that's how it's referred to in the code: Vector/modules/ext.vector.editWarning.js, etc.
Comment 3 Michael M. 2011-07-30 07:22:41 UTC
Created attachment 8846 [details]
Proposed patch

The warning is shown by the beforeunload handler, but this handler is removed when any form is submitted though it should be removed only if the editform is submitted.
The patch fixes this. Additionally I used mw.config.get for the global variable and changed some other stuff (mediaWiki -> mw, size() -> length, === for comparison to 0).
Comment 4 Mark A. Hershberger 2011-07-30 20:05:41 UTC
Clicking "stay on page" on the dialog that pops up now after using the enter key in the search field

... doesn't stop you from leaving the page.  Tested on FF5.

Works as expected otherwise.
Comment 5 Michael M. 2011-08-04 07:52:56 UTC
Created attachment 8882 [details]
Proposed patch - part 2

Found the culprit in jquery.suggestions.js. When you press enter, the javascript tries to submit the form, so editwarning triggers correctly. Editwarning unbinds the onbeforeunload handler (caching reasons in Firefox). Then the default reaction to the enter key is done: the form is submitted again (probably browser specific).
This patch simply prevents this default.
Both patches together should solve the problem thoroughly.
Comment 6 Dan Barrett 2011-08-08 15:43:33 UTC
The proposed 2 patches work for me in Firefox and Chrome.

In Internet Explorer 8, however, the edit warning is not appearing at all (in Vector skin) at this point.
Comment 7 Dan Barrett 2012-01-26 18:59:31 UTC
How about making this part of 1.19?  It can lead to data loss (e.g., the user does a search while on the edit page, and unwittingly loses whatever she was working on).
Comment 8 Dan Barrett 2012-01-26 19:00:24 UTC
My earlier comment #6 about Internet Explorer should be ignored. The edit warning is indeed appearing in IE.
Comment 9 Sumana Harihareswara 2012-02-10 21:15:24 UTC
Michael, sorry for the wait; there's been a bit of a delay in the review of patches here.  As we prepare to get a new version out, we're in a "code slush" during which we concentrate on reviewing code that has already been committed to our source code repository (see
http://thread.gmane.org/gmane.science.linguistics.wikipedia.technical/57950 for
more details).

I hope to get a reviewer to check your contribution soon.  In the interim, if you want, you could mark your old patches obsolete and simply combine them into one patch and attach it, which would be slightly easier for us to test and apply.

Thanks for the patch!
Comment 10 Sumana Harihareswara 2012-04-24 17:47:42 UTC
Dan, have you gotten a Developer access account yet?

https://www.mediawiki.org/wiki/Developer_access
Comment 11 Dan Barrett 2012-04-24 18:09:52 UTC
Thanks Sumana. I have not requested developer access due to lack of time for any development. Maybe in the future.
Comment 12 Rob Moen 2012-04-24 19:00:49 UTC
Thank you for the patch Michael.  I've applied part of this fix as the code
base has changed a bit since you posted.  Seems to be working now in FF,
Chrome, and IE.

Status of the change can be viewed here.
https://gerrit.wikimedia.org/r/#change,5734
Comment 13 Michael M. 2012-06-12 08:42:26 UTC
(Quote from comment #4)
> Clicking "stay on page" on the dialog that pops up now after using the enter
> key in the search field
> 
> ... doesn't stop you from leaving the page.  Tested on FF5.

Still reproducible, please also apply the second part of the proposed patch. (Due to bug 37479 you have to press enter in an empty search field.)
Comment 14 Krinkle 2012-06-26 04:02:35 UTC
(In reply to comment #13)
> (Quote from comment #4)
> > Clicking "stay on page" on the dialog that pops up now after using the enter
> > key in the search field
> > 
> > ... doesn't stop you from leaving the page.  Tested on FF5.
> 
> Still reproducible, please also apply the second part of the proposed patch.
> (Due to bug 37479 you have to press enter in an empty search field.)

When you tested it it may not have been deployed yet. Merging is not the same as deploying (every 2 weeks, the latest merge state in master is deployed).

Can you try again now?
Comment 15 Michael M. 2012-06-26 07:42:56 UTC
(In reply to comment #14)
> When you tested it it may not have been deployed yet. Merging is not the same
> as deploying (every 2 weeks, the latest merge state in master is deployed).
> 
> Can you try again now?

I tested it on mw.org, where 1.20wmf5 was already deployed at that time. And yes, I can still reproduce it on any WMF wiki.

1. Enable EditWarning in your preferences.
2. Open a page in edit mode.
3. Type something to change the text.
4. Press <Enter> in the empty search field.
5. A message will pop up, asking you if you really want to leave the page (as expected), click "Stay on page"
6. Despite your choice you will leave the page, and go to Special:Search.

Reproducible at least with Firefox (if I remember correctly, FF submits a form when you press enter; in SimpleSearch there is a missing event.preventDefault(), so the search form is submitted twice, while edit warning only catches it once).
Comment 16 Sumana Harihareswara 2012-10-14 21:55:22 UTC
I just reproduced this on test.wikipedia.org, which is running MW core from a day ago and Vector code from Sept. 30th.

In fact the case is slightly worse now than it was in June.  (A regression, but not necessarily a regression within the last 2 weeks so I'm not keywording it as a regression.)  We once more have the situation as described in the original bug report:

1. Enable EditWarning in your preferences (Special:Preferences#mw-prefsection-editing, "Warn me when I leave an edit page with unsaved changes").
2. Open a page in edit mode.
3. Type something to change the text.
4. Press <Enter> in the empty search field.
5. The "do you really want to leave?" message DOES NOT pop up; you will leave the page, and go to Special:Search.

This will lead to data loss by people who aren't quick-thinking enough to immediately hit the Back button.  Thus increasing the priority.
Comment 17 Rob Moen 2012-11-30 00:33:03 UTC
I can only reproduce this original bug in Firefox.
I have submitted Michael's second patch in https://gerrit.wikimedia.org/r/#/c/36123/
Which, I have testing and seems to fix this bug.

This change is not yet merged, though I have pulled it to the micro-design instance for testing.
http://micro-design.wmflabs.org/index.php?title=Main_Page&action=edit
Comment 18 Sumana Harihareswara 2012-11-30 00:57:51 UTC
This is now fixed in Vector.  Thanks for the fix, Rob!

Problem still happens in Monobook in Firefox.

Also there's an edge case where it still happens in Vector, as Rob and I just discovered:

1. Enable EditWarning in your preferences
(Special:Preferences#mw-prefsection-editing, "Warn me when I leave an edit page
with unsaved changes").
2. Open a page in edit mode.
3. Type something to change the text.
4. Press <Enter> in the empty search field.
5. The "do you really want to leave?" message pops up. Hit Leave Page.
6. On the new page, hit Back.
7. Now click in the search field and hit <Enter>.  Even though the article text has changed and not been saved, the "wait, really?" dialog box does NOT pop up, defying the promise of the edit warning preference! This is because the page is loaded and we don't detect a text change.

Now this is lower-priority, I think.
Comment 19 Krinkle 2013-04-29 21:55:15 UTC
Change-Id: I3cb40f70bf332e4aa53cd656b1c847b5f4637360
Comment 20 Krinkle 2013-04-29 22:05:58 UTC
(In reply to comment #18)
> This is now fixed in Vector.  Thanks for the fix, Rob!
> 
> Problem still happens in Monobook in Firefox.
> 

I can no longer reproduce the bug in Vector, Monobook both in both Chrome and Firefox.

> Also there's an edge case where it still happens in Vector, as Rob and I just
> discovered:
> 
> 1. Enable EditWarning in your preferences
> (Special:Preferences#mw-prefsection-editing, "Warn me when I leave an edit
> page
> with unsaved changes").
> 2. Open a page in edit mode.
> 3. Type something to change the text.
> 4. Press <Enter> in the empty search field.
> 5. The "do you really want to leave?" message pops up. Hit Leave Page.
> 6. On the new page, hit Back.
> 7. Now click in the search field and hit <Enter>.  Even though the article
> text has changed and not been saved, the "wait, really?" dialog box does
> NOT pop up,
> defying the promise of the edit warning preference! This is because the page
> is loaded and we don't detect a text change.

Confirmed that this bug is still happening in Chrome and Firefox in both Vector and Monobook.

However the patch submitted on this bug (in Gerrit as I3cb40f70bf) does NOT fix it (no visible change in behaviour).
Comment 21 Mayank Madan 2013-11-19 07:24:31 UTC
I cant reproduce the original bug but when i press enter in an empty search box while editing a page, then even if i choose stay on page, it still go to the search page discarding all the changes.
Reproduced on FireFox
Comment 22 Andre Klapper 2013-11-19 10:39:03 UTC
Confirming comment 21 with Firefox 25.0 with settings described in comment 18.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links