🐛 Force-display the preview button after render()

Some tests indicate, that the `ppcp-hidden` and `ppcp-enabled` events are not always triggered on some sites. As the preview button is refreshed during those events, it would stay hidden on those sites.

Adding a delayed DOM show() call solves the issue in a slightly less-elegant way.
This commit is contained in:
Philipp Stracker 2024-06-14 19:19:55 +02:00
parent c0c4d8d514
commit f759ca4573
No known key found for this signature in database

View file

@ -129,6 +129,17 @@ class PreviewButton {
}
this.createButton(previewButtonConfig);
/*
* Unfortunately, a hacky way that is required to guarantee that this preview button is
* actually visible after calling the `render()` method. On some sites, we've noticed that
* certain JS events (like `ppcp-hidden`) do not fire in the expected order. This causes
* problems with preview buttons not being displayed instantly.
*
* Using a timeout here will make the button visible again at the end of the current
* event queue.
*/
setTimeout(() => this.domWrapper.show());
}
remove() {