Delay appearing input focus (#1001)

This commit is contained in:
Jonatan Kłosko 2022-02-14 21:22:58 +01:00 committed by GitHub
parent 353e1f7889
commit 5cb0c68c41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -96,7 +96,12 @@ window.liveSocket = liveSocket;
// Handling custom events dispatched with JS.dispatch/3
window.addEventListener("lb:focus", (event) => {
event.target.focus();
// The element may be about to show up via JS.show, which wraps the
// change in requestAnimationFrame, so we do the same to make sure
// the focus is applied only after we change the element visibility
requestAnimationFrame(() => {
event.target.focus();
});
});
window.addEventListener("lb:set_value", (event) => {