Skip to content

Commit cde55a7

Browse files
committed
Fix translating text in button menus
1 parent d2e4d36 commit cde55a7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/components/buttonMenuToggle.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export default function ButtonMenuToggle({
9797
closeTimeout = undefined;
9898
};
9999

100+
// * fix translation by deleting text elements on close
101+
const canDeleteTextElementsOnClose = buttons.filter((button) => !button.textElement);
102+
const previousButtons = buttons.slice();
103+
100104
let element: HTMLElement, closeTimeout: number, tempId = 0;
101105
ButtonMenuToggleHandler({
102106
el: button,
@@ -115,6 +119,10 @@ export default function ButtonMenuToggle({
115119
return;
116120
}
117121

122+
const newButtons = filteredButtons.slice().filter((button) => !previousButtons.includes(button));
123+
previousButtons.push(...newButtons);
124+
canDeleteTextElementsOnClose.push(...newButtons.filter((button) => !button.textElement));
125+
118126
const _element = element = await ButtonMenu({
119127
buttons: filteredButtons,
120128
listenerSetter
@@ -152,6 +160,7 @@ export default function ButtonMenuToggle({
152160
try {button.dispose?.();} catch{}
153161
button.element = undefined;
154162
});
163+
canDeleteTextElementsOnClose.forEach((button) => delete button.textElement);
155164
element.remove();
156165
}, 300);
157166
}

0 commit comments

Comments
 (0)