From 448ebb501922335564a99e44dba128bd9da204dd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 21 Jun 2021 21:04:31 -0700 Subject: [PATCH] GUACAMOLE-724: Ensure focus is not retained when transferring a client from an unattached group to an attached group. --- .../src/app/client/services/guacClientManager.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js b/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js index b1817a0dd..e7821f220 100644 --- a/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js +++ b/guacamole/src/main/frontend/src/app/client/services/guacClientManager.js @@ -95,8 +95,20 @@ angular.module('client').factory('guacClientManager', ['$injector', // Remove client from all groups managedClientGroups.forEach(group => { - _.remove(group.clients, client => (client.id === id)); - ManagedClientGroup.recalculateTiles(group); + var removed = _.remove(group.clients, client => (client.id === id)); + if (removed.length) { + + // Reset focus state if client is being removed from a group + // that isn't currently attached (focus may otherwise be + // retained and result in a newly added connection unexpectedly + // sharing focus) + if (!group.attached) + removed.forEach(client => { client.clientProperties.focused = false; }); + + // Recalculate group grid if number of clients is changing + ManagedClientGroup.recalculateTiles(group); + + } }); // Remove any groups that are now empty