Skip to content

Commit 94a9085

Browse files
committed
[FIX] GridOverlay: Prevent mousedown default when selecting range
When selecting a range in the grid and the composer is open, passing your selection around the composer will see its content selected as if we were actually selecting text inside the composer. This behaviour is a direct effect of the default behaviour of the mousedown event that starts the selection. Since the focus is kept on the composer at all times, the browser behaves as if we had clicked on the composer itself even if from a user point of view, it makes little sense. Task: 5344285
1 parent 60a66b6 commit 94a9085

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

src/components/composer/composer/composer.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
t-on-keydown="onKeydown"
1313
t-on-mousewheel.stop=""
1414
t-on-input="onInput"
15-
t-on-mousedown="onMousedown"
15+
t-on-mousedown.prevent="onMousedown"
1616
t-on-click="onClick"
1717
t-on-keyup="onKeyup"
1818
t-on-paste="onPaste"

src/components/grid/grid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ export class Grid extends Component<Props, SpreadsheetChildEnv> {
469469
// When selecting cells during the edition, we don't want to avoid the default
470470
// browser behaviour that will select the text inside the composer
471471
// (see related commit msg for more information)
472-
ev.preventDefault();
472+
// ev.preventDefault();
473473
if ((col !== prevCol && col != -1) || (row !== prevRow && row != -1)) {
474474
prevCol = col === -1 ? prevCol : col;
475475
prevRow = row === -1 ? prevRow : row;

src/components/grid_overlay/grid_overlay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export class GridOverlay extends Component<Props, SpreadsheetChildEnv> {
228228
// not main button, probably a context menu
229229
return;
230230
}
231+
ev.preventDefault();
231232
const [col, row] = this.getCartesianCoordinates(ev);
232233
this.props.onCellClicked(col, row, {
233234
expandZone: ev.shiftKey,

src/components/helpers/drag_and_drop_hook.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class DOMDndHelper {
182182
}
183183

184184
onMouseMove(ev: MouseEvent) {
185+
ev.preventDefault();
185186
if (ev.button !== 0) {
186187
this.onCancel();
187188
return;

0 commit comments

Comments
 (0)