[FIX] web_editor: remove toolbar on tab in table
Before this commit: - On table when we hit tab it displays toolbar as it sets selection between startPosition and endPosition. - On hitting tab it selects the text in the next cell completely, which should not happen. After this commit: - Now toolbar is not displayed on hitting tab. - selectionis made to collapse at the end the lastNode of the cell. task-3475079 closes odoo/odoo#151653 X-original-commit: 9361133a24146528846cd2d69119c3e9045eafba Signed-off-by: Antoine Guenet (age) <age@odoo.com>
This commit is contained in:
@@ -16,7 +16,6 @@ import {
|
||||
commonParentGet,
|
||||
containsUnremovable,
|
||||
DIRECTIONS,
|
||||
endPos,
|
||||
ensureFocus,
|
||||
getCursorDirection,
|
||||
getFurthestUneditableParent,
|
||||
@@ -28,7 +27,6 @@ import {
|
||||
preserveCursor,
|
||||
setCursorStart,
|
||||
setSelection,
|
||||
startPos,
|
||||
toggleClass,
|
||||
closestElement,
|
||||
isVisible,
|
||||
@@ -80,6 +78,7 @@ import {
|
||||
boundariesOut,
|
||||
getFontSizeDisplayValue,
|
||||
rightLeafOnlyNotBlockPath,
|
||||
lastLeaf,
|
||||
} from './utils/utils.js';
|
||||
import { editorCommands } from './commands/commands.js';
|
||||
import { Powerbox } from './powerbox/Powerbox.js';
|
||||
@@ -5069,7 +5068,7 @@ export class OdooEditor extends EventTarget {
|
||||
const cursorDestination =
|
||||
tds[tds.findIndex(td => closestTd === td) + (direction === DIRECTIONS.LEFT ? -1 : 1)];
|
||||
if (cursorDestination) {
|
||||
setSelection(...startPos(cursorDestination), ...endPos(cursorDestination), true);
|
||||
setCursorEnd(lastLeaf(cursorDestination));
|
||||
} else if (direction === DIRECTIONS.RIGHT) {
|
||||
this.execCommand('addRow', 'after');
|
||||
this._onTabulationInTable(ev);
|
||||
|
||||
@@ -5106,7 +5106,14 @@ X[]
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<table><tbody><tr style="height: 20px;"><td style="width: 20px;">ab</td><td>cd</td><td>ef[]</td></tr></tbody></table>',
|
||||
stepFunction: async editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab'}),
|
||||
contentAfter: '<table><tbody><tr style="height: 20px;"><td style="width: 20px;">ab</td><td>cd</td><td>ef</td></tr><tr style="height: 20px;"><td>[<p><br></p>]</td><td><p><br></p></td><td><p><br></p></td></tr></tbody></table>',
|
||||
contentAfter: '<table><tbody><tr style="height: 20px;"><td style="width: 20px;">ab</td><td>cd</td><td>ef</td></tr><tr style="height: 20px;"><td><p>[]<br></p></td><td><p><br></p></td><td><p><br></p></td></tr></tbody></table>',
|
||||
});
|
||||
});
|
||||
it('should not select whole text of the next cell', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<table><tbody><tr style="height: 20px;"><td style="width: 20px;">ab</td><td>[cd]</td><td>ef</td></tr></tbody></table>',
|
||||
stepFunction: async editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab'}),
|
||||
contentAfter: '<table><tbody><tr style="height: 20px;"><td style="width: 20px;">ab</td><td>cd</td><td>ef[]</td></tr></tbody></table>',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user