-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Dismiss" button not persistently dismissing notices #14
Comments
Hmm, on further investigation this might be a browser bug. It works fine in Chrome (88.0.4324.150), but not in Firefox (85.0.1). |
It's not a browser bug, it's a race condition. The HTML generated is just a DIV with the relevant classes: Line 180 in 42101e8
WordPress's common.js then adds the dismiss button to the div. WPTRT admin-notices's JavaScript is printed on I tried to use What does work is to wrap the existing JavaScript in a timer:
Or to use a MutationObserver to watch until the Looking again at common.js, it's using I toyed around a little with that too – trying to use similar JavaScript but loaded after common.js – but didn't get it working. Maybe someone handy with JavaScript could suggest how to achieve it. |
I worked on this again yesterday. I'll be testing this change: master...BrianHenryIE:admin-notices:fix-race-condition-#14 The changes are mostly:
|
Because of #18 I'm now using an unpatched version of the library and can confirm the issue is still present with Firefox. |
I found I would dismiss notices, but on reloading the page they'd be back. The option wasn't being set in the site's options table.
Further investigation showed that the javascript console was seeing an error:
dismissBtn
was coming back null.I changed the file
src/Dismiss.php
from this:to this:
...and it worked. It appears that the class
.notice-dismiss
isn't being added.I'm running WordPress 5.6.1.
The text was updated successfully, but these errors were encountered: