-
-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Hello rc-dock maintainers!
I have recently been working on getting document focus right in my application that uses [email protected]. I stumbled upon the realization that running updateTab
with makeActive
set to false
causes the dock layout to set the document focus to the panel containing that updated tab. It does this by setting this.panelToFocus
. I can't seem to think of why this functionality would be desirable, but I expect maybe I'm not thinking of some important situation. Could you explain why updateTab
with makeActive
set to false
focuses the panel?
This focusing functionality seems to have been added in this commit. It seems it was published somewhere around version 3.0.14
, but the commit message and the changelog don't mention why this change was made.
I made the following patch that disables this functionality because I want the focus to stay where it is even if some tab in some other panel receives an update that is not set to makeActive
:
diff --git a/node_modules/rc-dock/es/DockLayout.js b/node_modules/rc-dock/es/DockLayout.js
index bac288d..8047e9f 100644
--- a/node_modules/rc-dock/es/DockLayout.js
+++ b/node_modules/rc-dock/es/DockLayout.js
@@ -258,7 +258,17 @@ export class DockLayout extends DockPortalManager {
if (!makeActive) {
// restore the previous activeId
panelData.activeId = activeId;
- this.panelToFocus = panelData.id;
+ /**
+ * patch-package notes:
+ *
+ * Focusing the panel the updated tab belongs to if we were not making the tab
+ * active led to the panel being focused when not intended. For example, if the
+ * user performs some action in some tab that causes a tab in another panel to
+ * change its title, that should not cause that other panel the user is not
+ * working in to be focused. The user should be able to continue working
+ * in the tab they were working in previously.
+ */
+ // this.panelToFocus = panelData.id;
}
}
else if (makeActive && panelData.activeId !== id) {
I can make a PR to fix this if you'd like. I just didn't want to make a PR to disable this without knowing why this code is here in the first place because I might be breaking something important.
As always, thanks for your hard work on this great library.