Opened 10 years ago
Closed 9 years ago
#27657 closed defect (bug) (fixed)
Clicking 'Publish' before autosave fires does not publish a post
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Autosave | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
Attachments (4)
Change History (13)
#2
@
9 years ago
Added a small patch to hopefully fix this.
So, the blur event from wp-admin\js\post.js triggers an autosave when the #title
input field is blurred. For some reason, if this autosave is triggered, submitting / publishing the post will not be triggered. Instead, the save trigger just seems to get ignored.
Adding a small timeout of 100ms to the blur event seems to have fixed the issue on minor testing, but I'm not 100% on what the impact of adding a timeout may be.
Testing the event by adding a title then causing the #title
input field to lose focus still triggers an intended autosave, just 100ms later.
I presume @davidmarichal's attempt to remove the blur
event for #title
was to prevent the autosave from occurring, but the blur
event will typically be triggered before the publish button is clicked (jsFiddle).
#4
follow-up:
↓ 6
@
9 years ago
- Keywords needs-patch removed
The blur event has the property relatedTarget.
The publish button is set as the relatedTarget if clicked. So then on blur, I check if the relatedTarget is equal to any of the submit buttons and return false. (jsFiddle)
Hope this fixes the issue.
#5
@
9 years ago
Was testing something similar to 27657.2.patch. That should do it. It is the right approach and seems jQuery normalizes relatedTarget
.
#6
in reply to:
↑ 4
@
9 years ago
- Keywords has-patch added
Replying to davidmarichal:
The blur event has the property relatedTarget.
The publish button is set as the relatedTarget if clicked. So then on blur, I check if the relatedTarget is equal to any of the submit buttons and return false. (jsFiddle)
Hope this fixes the issue.
Excellent, tried the fiddle and the approach makes sense. Could maybe use more testing in trunk, seems good though - thanks!
#7
@
9 years ago
...seems jQuery normalizes relatedTarget
Scratch that. On further testing relatedTarget is not set in IE. Can keep the same approach but needs more code :)
@davidmarichal thanks for your contribution!
testing your patch I am still able to reproduce the bug @jeremyfelt reported :(
It doesn't always happen - to reproduce, I'm typing a bit and quickly clicking publish without clicking anywhere else on the page - here is a screencast showing the issue with the patch applied. Note that after clicking publish I only get a draft, the post is not published.
Can you explain your thinking with the approach of unbinding the title blur handler?