From 5bfe6dc5d1e0aeb1ab3e372821997d83ba5c9164 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 15 Apr 2016 16:51:18 +0100 Subject: Rework UI component focus handling. The code to handle the focus for UI components has been tweaked and adapted over time, and has become quite complicated (and brittle). This reworks it from scratch, and co-locates similar code which does related things. Fixes #2099. --- content_scripts/hud.coffee | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'content_scripts/hud.coffee') diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index bbf7c5e9..fb1fd657 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -25,12 +25,12 @@ HUD = show: (text) -> return unless @isReady() clearTimeout(@_showForDurationTimerId) - @hudUI.show {name: "show", text} + @hudUI.activate {name: "show", text} @tween.fade 1.0, 150 showFindMode: (@findMode = null) -> return unless @isReady() - @hudUI.show {name: "showFindMode", text: ""} + @hudUI.activate name: "showFindMode", text: "" @tween.fade 1.0, 150 search: (data) -> @@ -50,9 +50,7 @@ HUD = clearTimeout(@_showForDurationTimerId) @tween.stop() if immediate - unless updateIndicator - @hudUI.hide() - @hudUI.postMessage {name: "hide"} + @hudUI.hide() Mode.setIndicator() if updateIndicator else @tween.fade 0, 150, => @hide true, updateIndicator @@ -60,9 +58,9 @@ HUD = hideFindMode: (data) -> @findMode.checkReturnToViewPort() - # An element element won't receive a focus event if the search landed on it while we were in the HUD - # iframe. To end up with the correct modes active, we create a focus/blur event manually after refocusing - # this window. + # An element won't receive a focus event if the search landed on it while we were in the HUD iframe. To + # end up with the correct modes active, we create a focus/blur event manually after refocusing this + # window. window.focus() focusNode = DomUtils.getSelectionFocusElement() -- cgit v1.2.3 From f3aba1914dc645d4de15ff6e6a9104dcb99018ee Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 16 Apr 2016 14:30:05 +0100 Subject: Remove dead code from the HUD initialization. --- content_scripts/hud.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'content_scripts/hud.coffee') diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index fb1fd657..32662861 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -30,7 +30,7 @@ HUD = showFindMode: (@findMode = null) -> return unless @isReady() - @hudUI.activate name: "showFindMode", text: "" + @hudUI.activate name: "showFindMode" @tween.fade 1.0, 150 search: (data) -> -- cgit v1.2.3 From 59d6ce006da3cb125252dfd98819daf65650781e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 16 Apr 2016 14:43:15 +0100 Subject: Self code review re. ui-component focus handling. --- content_scripts/hud.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'content_scripts/hud.coffee') diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 32662861..0bd1df3e 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -50,8 +50,7 @@ HUD = clearTimeout(@_showForDurationTimerId) @tween.stop() if immediate - @hudUI.hide() - Mode.setIndicator() if updateIndicator + if updateIndicator then Mode.setIndicator() else @hudUI.hide() else @tween.fade 0, 150, => @hide true, updateIndicator -- cgit v1.2.3