Skip to content

Commit 4fb054c

Browse files
authored
fix: Recreate the dropdowndiv when clearing it. (#8903)
1 parent 5b103e1 commit 4fb054c

1 file changed

Lines changed: 4 additions & 29 deletions

File tree

core/dropdowndiv.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ export function createDom() {
133133
// Transition animation for transform: translate() and opacity.
134134
div.style.transition =
135135
'transform ' + ANIMATION_TIME + 's, ' + 'opacity ' + ANIMATION_TIME + 's';
136-
137-
// Handle focusin/out events to add a visual indicator when
138-
// a child is focused or blurred.
139136
}
140137

141138
/**
@@ -166,8 +163,8 @@ export function getContentDiv(): HTMLDivElement {
166163

167164
/** Clear the content of the drop-down. */
168165
export function clearContent() {
169-
content.textContent = '';
170-
content.style.width = '';
166+
div.remove();
167+
createDom();
171168
}
172169

173170
/**
@@ -338,12 +335,8 @@ export function show<T>(
338335
const mainWorkspace = common.getMainWorkspace() as WorkspaceSvg;
339336
renderedClassName = mainWorkspace.getRenderer().getClassName();
340337
themeClassName = mainWorkspace.getTheme().getClassName();
341-
if (renderedClassName) {
342-
dom.addClass(div, renderedClassName);
343-
}
344-
if (themeClassName) {
345-
dom.addClass(div, themeClassName);
346-
}
338+
dom.addClass(div, renderedClassName);
339+
dom.addClass(div, themeClassName);
347340

348341
// When we change `translate` multiple times in close succession,
349342
// Chrome may choose to wait and apply them all at once.
@@ -645,31 +638,13 @@ export function hideWithoutAnimation() {
645638
clearTimeout(animateOutTimer);
646639
}
647640

648-
// Reset style properties in case this gets called directly
649-
// instead of hide() - see discussion on #2551.
650-
div.style.transform = '';
651-
div.style.left = '';
652-
div.style.top = '';
653-
div.style.opacity = '0';
654-
div.style.display = 'none';
655-
div.style.backgroundColor = '';
656-
div.style.borderColor = '';
657-
658641
if (onHide) {
659642
onHide();
660643
onHide = null;
661644
}
662645
clearContent();
663646
owner = null;
664647

665-
if (renderedClassName) {
666-
dom.removeClass(div, renderedClassName);
667-
renderedClassName = '';
668-
}
669-
if (themeClassName) {
670-
dom.removeClass(div, themeClassName);
671-
themeClassName = '';
672-
}
673648
(common.getMainWorkspace() as WorkspaceSvg).markFocused();
674649
}
675650

0 commit comments

Comments
 (0)