Skip to content

Commit

Permalink
Add option to disable workspace auto focus
Browse files Browse the repository at this point in the history
Resolve #40

Signed-off-by: Songlin Jiang <[email protected]>
  • Loading branch information
HollowMan6 committed Feb 27, 2024
1 parent 3e7bc0e commit 74b99b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ options = {
// Keep the fields of multiple selected same-type blocks with the same value
multiFieldUpdate: true,

// Auto focus the workspace when the mouse enters.
workspaceAutoFocus: true,

// Use custom icon for the multi select controls.
multiselectIcon: {
hideIcon: false,
Expand Down
3 changes: 2 additions & 1 deletion src/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class Multiselect {
this.onFocusOutWrapper_ = Blockly.browserEvents.conditionalBind(
injectionDiv, 'focusout', this, this.onBlur_);
injectionDiv.addEventListener('mouseenter', () => {
if (document.activeElement === this.workspace_.svgGroup_.parentElement ||
if (options.workspaceAutoFocus === false ||
document.activeElement === this.workspace_.svgGroup_.parentElement ||
document.activeElement.nodeName.toLowerCase() === 'input' ||
document.activeElement.nodeName.toLowerCase() === 'textarea') {
return;
Expand Down

0 comments on commit 74b99b0

Please sign in to comment.