mike-jumper commented on code in PR #942:
URL: https://github.com/apache/guacamole-client/pull/942#discussion_r1450898050


##########
guacamole/src/main/frontend/src/app/client/controllers/clientController.js:
##########
@@ -139,6 +139,21 @@ angular.module('client').controller('clientController', 
['$scope', '$routeParams
 
     };
 
+    /**
+     * True if and only if a "guacFieldFocused" event was received, and a
+     * corresponding "guacFieldBlurred" event has not yet been received.
+     * This is intended to allow fields to receive keyboard input even when
+     * the menu is not being shown.
+     *
+     * @type {boolean}
+     */
+    $scope.fieldIsFocused = false;
+
+    // Enable and disable the custom field focused state as the relevant
+    // events are received
+    $scope.$on('guacFieldFocused', () => $scope.fieldIsFocused = true);
+    $scope.$on('guacFieldBlurred', () => $scope.fieldIsFocused = false);

Review Comment:
   If multiple extensions emit these events, depending on the order things are 
processed, it looks possible that extension X might emit `guacFieldBlurred` 
after extension Y emits `guacFieldFocused`, causing `$scope.fieldIsFocused` to 
erroneously report `false`.
   
   I think the way focus is tracked here should be modified such that this is 
not possible.
   
   Another thought: would it make sense for any such extension to instead 
directly handle `guacBeforeKeydown` and `guacBeforeKeyup` on its own? I don't 
think there's anything preventing multiple listeners for those events from 
invoking `preventDefault()` according to their own, independent criteria. If 
that's the case, then there would be no need for these additional events and 
corresponding flag.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to