From 545c8d8053fb9e8bd307c641adc4526f92bbe0ac Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 26 Oct 2023 17:38:32 +0200 Subject: [PATCH 1/4] Update factory.js not to focus on render if there's an activeElement with class tc-focus-keep --- core/modules/editor/factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 6157ec67fd8..9835af4cbc6 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -71,7 +71,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { // Fix height this.engine.fixHeight(); // Focus if required - if(this.editFocus === "true" || this.editFocus === "yes") { + if((this.editFocus === "true" || this.editFocus === "yes") && !$tw.utils.hasClass(parent.ownerDocument.activeElement,"tc-focus-keep")) { this.engine.focus(); } // Add widget message listeners From b15b7f6bcd04e0dcd2f83138c220ec994bdfffd4 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 26 Oct 2023 17:39:47 +0200 Subject: [PATCH 2/4] Update type.tid adding the class tc-focus-keep to the created input field --- core/ui/EditTemplate/type.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ui/EditTemplate/type.tid b/core/ui/EditTemplate/type.tid index c1c38b72ae7..f74d70a9db1 100644 --- a/core/ui/EditTemplate/type.tid +++ b/core/ui/EditTemplate/type.tid @@ -10,7 +10,7 @@ first-search-filter: [all[shadows+tiddlers]prefix[$:/language/Docs/Types/]sort[d <>
<$fieldmangler> -<$macrocall $name="keyboard-driven-input" tiddler=<> storeTitle=<> refreshTitle=<> selectionStateTitle=<> field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<> class="tc-edit-typeeditor tc-edit-texteditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[type]then[true]] ~[[false]] }}} cancelPopups="yes" configTiddlerFilter="[[$:/core/ui/EditTemplate/type]]" inputCancelActions=<>/><$button popup=<> class="tc-btn-invisible tc-btn-dropdown tc-small-gap" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}<$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}<$action-deletetiddler $filter="[] [] [] []"/> +<$macrocall $name="keyboard-driven-input" tiddler=<> storeTitle=<> refreshTitle=<> selectionStateTitle=<> field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<> class="tc-edit-typeeditor tc-edit-texteditor tc-popup-handle tc-focus-keep" tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[type]then[true]] ~[[false]] }}} cancelPopups="yes" configTiddlerFilter="[[$:/core/ui/EditTemplate/type]]" inputCancelActions=<>/><$button popup=<> class="tc-btn-invisible tc-btn-dropdown tc-small-gap" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}<$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}<$action-deletetiddler $filter="[] [] [] []"/>
From 88678298ce213f479385446d1d3e292bcfd4f422 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 26 Oct 2023 17:44:08 +0200 Subject: [PATCH 3/4] Update factory.js --- core/modules/editor/factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 9835af4cbc6..e87f838756c 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -71,7 +71,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { // Fix height this.engine.fixHeight(); // Focus if required - if((this.editFocus === "true" || this.editFocus === "yes") && !$tw.utils.hasClass(parent.ownerDocument.activeElement,"tc-focus-keep")) { + if((this.editFocus === "true" || this.editFocus === "yes") && $tw.browser && !$tw.utils.hasClass(parent.ownerDocument.activeElement,"tc-focus-keep")) { this.engine.focus(); } // Add widget message listeners From facb7ed4c3f12504209f8ae8ff3d442ea7427652 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 26 Oct 2023 18:33:27 +0200 Subject: [PATCH 4/4] Update factory.js --- core/modules/editor/factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index e87f838756c..6a5c9847b32 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -71,7 +71,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { // Fix height this.engine.fixHeight(); // Focus if required - if((this.editFocus === "true" || this.editFocus === "yes") && $tw.browser && !$tw.utils.hasClass(parent.ownerDocument.activeElement,"tc-focus-keep")) { + if($tw.browser && (this.editFocus === "true" || this.editFocus === "yes") && !$tw.utils.hasClass(parent.ownerDocument.activeElement,"tc-focus-keep")) { this.engine.focus(); } // Add widget message listeners