preserve the focused element when replacing entry in-place
This commit is contained in:
parent
0cffb564ea
commit
2a52139b6a
|
@ -304,7 +304,14 @@ function createStyleElement({
|
|||
if (check) detectSloppyRegexps([style]);
|
||||
|
||||
const oldElement = $(ENTRY_ID_PREFIX + style.id);
|
||||
if (oldElement) {
|
||||
if (oldElement && oldElement.contains(document.activeElement)) {
|
||||
// preserve the focused element inside
|
||||
const {className} = document.activeElement;
|
||||
oldElement.parentNode.replaceChild(entry, oldElement);
|
||||
// we're not using $() since className may contain multiple tokens
|
||||
const el = entry.getElementsByClassName(className)[0];
|
||||
if (el) el.focus();
|
||||
} else if (oldElement) {
|
||||
oldElement.parentNode.replaceChild(entry, oldElement);
|
||||
} else {
|
||||
container.appendChild(entry);
|
||||
|
|
Loading…
Reference in New Issue
Block a user