From 24ab50d49d3fddcbf270743883121435fad078ce Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 3 Dec 2024 13:41:32 -0800 Subject: [PATCH] fix: Fix bug that caused text to be selected when long-pressing in the workspace on a touch device. (#8670) * fix: Fix bug that caused text to be selected when long-pressing in the workspace on a touch device. * chore: Fix test failure. --- core/css.ts | 13 ++----------- core/toolbox/toolbox.ts | 1 - tests/mocha/toolbox_test.js | 5 +---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/core/css.ts b/core/css.ts index 20c573093..2186af04a 100644 --- a/core/css.ts +++ b/core/css.ts @@ -79,6 +79,8 @@ let content = ` position: relative; overflow: hidden; /* So blocks in drag surface disappear at edges */ touch-action: none; + user-select: none; + -webkit-user-select: none; } .blocklyNonSelectable { @@ -266,17 +268,6 @@ let content = ` cursor: default; } -/* - Don't allow users to select text. It gets annoying when trying to - drag a block and selected text moves instead. -*/ -.blocklySvg text { - user-select: none; - -ms-user-select: none; - -webkit-user-select: none; - cursor: inherit; -} - .blocklyHidden { display: none; } diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index 457d5d43b..120378393 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -197,7 +197,6 @@ export class Toolbox const toolboxContainer = document.createElement('div'); toolboxContainer.setAttribute('layout', this.isHorizontal() ? 'h' : 'v'); dom.addClass(toolboxContainer, 'blocklyToolboxDiv'); - dom.addClass(toolboxContainer, 'blocklyNonSelectable'); toolboxContainer.setAttribute('dir', this.RTL ? 'RTL' : 'LTR'); return toolboxContainer; } diff --git a/tests/mocha/toolbox_test.js b/tests/mocha/toolbox_test.js index 70f5ff8f9..3b69fac5d 100644 --- a/tests/mocha/toolbox_test.js +++ b/tests/mocha/toolbox_test.js @@ -47,10 +47,7 @@ suite('Toolbox', function () { test('Init called -> HtmlDiv is inserted before parent node', function () { const toolboxDiv = Blockly.common.getMainWorkspace().getInjectionDiv() .childNodes[0]; - assert.equal( - toolboxDiv.className, - 'blocklyToolboxDiv blocklyNonSelectable', - ); + assert.equal(toolboxDiv.className, 'blocklyToolboxDiv'); }); test('Init called -> Toolbox is subscribed to background and foreground colour', function () { const themeManager = this.toolbox.workspace_.getThemeManager();