Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit def88d5

Browse files
Gorashdmo-odoo
authored andcommitted
[FIX] DomLayout: don't change focus when edit an input or a textarea
1 parent 49f324f commit def88d5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/plugin-dom-layout/src/DomLayoutEngine.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
DomObjectRenderingEngine,
1717
} from '../../plugin-renderer-dom-object/src/DomObjectRenderingEngine';
1818
import { TagNode } from '../../core/src/VNodes/TagNode';
19-
import { flat, isContentEditable } from '../../utils/src/utils';
19+
import { flat, isContentEditable, nodeName } from '../../utils/src/utils';
2020
import { Modifier } from '../../core/src/Modifier';
2121
import { RenderingEngineCache } from '../../plugin-renderer/src/RenderingEngineCache';
2222
import { ChangesLocations } from '../../core/src/Memory/Memory';
@@ -608,6 +608,14 @@ export class DomLayoutEngine extends LayoutEngine {
608608
private _renderSelection(): void {
609609
const selection = this.editor.selection;
610610
const range = selection.range;
611+
612+
const activeNodeName = document.activeElement && nodeName(document.activeElement);
613+
if (activeNodeName === 'INPUT' || activeNodeName === 'TEXTAREA') {
614+
// Do not change the selection if the focus is set within an input
615+
// or a textarea so as not to lose that focus.
616+
return;
617+
}
618+
611619
if (selection.range.isCollapsed()) {
612620
// Prevent rendering a collapsed selection in a non-editable context.
613621
const target =

0 commit comments

Comments
 (0)