From e3c2a6e4cddf0ee77d8f83088491b3e130ad01b5 Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Thu, 25 Jul 2024 15:05:43 +0200 Subject: [PATCH] HFP-4085 Fix click handling --- src/scripts/h5p-crossword-table.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/scripts/h5p-crossword-table.js b/src/scripts/h5p-crossword-table.js index 27fd2cc..137d158 100644 --- a/src/scripts/h5p-crossword-table.js +++ b/src/scripts/h5p-crossword-table.js @@ -651,11 +651,6 @@ export default class CrosswordTable { * @param {boolean} [keepOrientation] If true, don't toggle orientation on repeated focus. */ handleCellClick(position, keepOrientation = false) { - if (this.ignoreNextClick) { - this.ignoreNextClick = false; - return; - } - const cell = this.cells[position.row][position.column]; if (!cell.getSolution()) { return; @@ -674,8 +669,14 @@ export default class CrosswordTable { } } - this.currentPosition = position; + if ( + this.currentPosition.row === position.row && + this.currentPosition.column === position.column + ) { + return; // No need to set the whole moveTo in motion again + } + this.currentPosition = position; this.moveTo(position, true); } @@ -698,8 +699,7 @@ export default class CrosswordTable { // Getting focus from outside the grid by tabbing into it this.setcurrentOrientation(this.currentOrientation, position); - this.handleCellClick(position, true); - this.ignoreNextClick = (typeof this.ignoreNextClick !== 'boolean') ? true : this.ignoreNextClick; // Can't determine first focus on click + this.handleCellClick(position, true, false); } /**