[FIX] web_editor: show the row table ui on the right for rtl languages

Before this commit, the row table UI toggler was positioned on the left
for RTL languages. Since the first TD was on the far right rather than
the far left, it was impossible to click on the row UI. It disappeared
whenever an attempt was made to click on it.

task-3664939

X-original-commit: fbc167bf84340b4bb6d0f8c59f2734814f56c6df
Part-of: odoo/odoo#148543
This commit is contained in:
Nicolas Bayet
2024-01-10 06:12:29 +00:00
parent 7e37f66839
commit e67b16fb79
@@ -2915,19 +2915,33 @@ export class OdooEditor extends EventTarget {
*/
_positionTableUi(element) {
const tableUiContainerRect = this._tableUiContainer.getBoundingClientRect();
const isRtl = this.options.direction === 'rtl';
const isRow = element.nodeName === 'TR';
const ui = isRow ? this._rowUi : this._columnUi;
const elementRect = element.getBoundingClientRect();
const wrappedUi = ui.firstElementChild;
const table = getInSelection(this.document, 'table');
const table = closestElement(element, 'table');
const tableRect = table && table.getBoundingClientRect();
const resetTableSize = ui.querySelector('.o_reset_table_size');
if (table && !table.hasAttribute('style')) {
resetTableSize.classList.add('d-none');
} else {
resetTableSize.classList.remove('d-none');
}
ui.style.left = elementRect.left - tableUiContainerRect.left - (isRow ? wrappedUi.clientWidth : 0) + 'px';
ui.style.top = elementRect.top - tableUiContainerRect.top - (isRow ? 0 : wrappedUi.clientHeight) + 'px';
let left;
let top;
if (isRow && isRtl) {
left = tableRect.right - tableUiContainerRect.x;
} else if (isRow && !isRtl) {
left = elementRect.left - tableUiContainerRect.left - (isRow ? wrappedUi.clientWidth : 0);
} else {
left = elementRect.left - tableUiContainerRect.left - (isRow ? wrappedUi.clientWidth : 0);
}
top = elementRect.top - tableUiContainerRect.top - (isRow ? 0 : wrappedUi.clientHeight);
ui.style.left = left + 'px';
ui.style.top = top + 'px';
wrappedUi.style[isRow ? 'height' : 'width'] = elementRect[isRow ? 'height' : 'width'] + 'px';
}