[beast/ebeast] EBEAST: grab focus asynchronously to work around Mithril 1.0.1 m.redraw



commit a4d534bd8c9a67277d9a69b1981fcdeec9b56b97
Author: Tim Janik <timj gnu org>
Date:   Tue Mar 7 00:51:55 2017 +0100

    EBEAST: grab focus asynchronously to work around Mithril 1.0.1 m.redraw
    
    Signed-off-by: Tim Janik <timj gnu org>

 ebeast/assets/dialogs.js |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/ebeast/assets/dialogs.js b/ebeast/assets/dialogs.js
index 36c7480..e98e1d6 100644
--- a/ebeast/assets/dialogs.js
+++ b/ebeast/assets/dialogs.js
@@ -109,6 +109,11 @@ function version_rows () {
     m ('tr', [ m ('th', 'Music Path:'),                m ('td', App.getPath ('music')) ]),
   ];
 }
+
+// Work around Mithril 1.0.1 m.redraw causing synchronous DOM updates during event handling
+const vnode_async_autofocus = function (vnode) {
+  Widgets.queue_animation_callback (function () { vnode.dom.focus() });
+};
 module.exports.about_dialog = function () {
   if (!App.show_about)
     return null;
@@ -121,7 +126,10 @@ module.exports.about_dialog = function () {
                      onclose: doclose,
                      buttons: [
                        m ('button', [ 'Toggle', ]),
-                       m ('button[autofocus]', { onclick: doclose }, [ 'Close', ]),
+                       m ('button', {
+                         oncreate: vnode_async_autofocus,
+                         onclick: doclose,
+                       }, [ 'Close', ]),
                        m ('button', [ 'Help', ]),
                      ] },
        m ('table', version_rows())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]