Skip to content

Commit 4634607

Browse files
committed
feat: update createMenuButton to support async onClick handlers and enhance loading mask z-index for improved visibility
1 parent c934a00 commit 4634607

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎index.ts‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ const createFixedActionButton = () => {
264264
border: 1px solid rgba(0, 0, 0, 0.08);
265265
`;
266266

267-
const createMenuButton = (text: string, onClick: () => void) => {
267+
const createMenuButton = (text: string, onClick: () => void | Promise<void>) => {
268268
// Create wrapper for the entire menu item
269269
const menuItem = document.createElement('div');
270270
menuItem.className = 'fab-menu-item';
@@ -297,9 +297,11 @@ const createFixedActionButton = () => {
297297
menuItem.style.background = 'transparent';
298298
});
299299

300-
button.addEventListener('click', () => {
301-
onClick();
300+
button.addEventListener('click', async () => {
302301
hideMenu();
302+
// Small delay to ensure menu hide animation completes before showing loading
303+
await new Promise((resolve) => setTimeout(resolve, 100));
304+
await onClick();
303305
});
304306

305307
menuItem.appendChild(button);
@@ -317,18 +319,18 @@ const createFixedActionButton = () => {
317319
}),
318320
);
319321
menuPanel.appendChild(
320-
createMenuButton(t('newWord'), () => {
321-
onCreateNew('.docx');
322+
createMenuButton(t('newWord'), async () => {
323+
await onCreateNew('.docx');
322324
}),
323325
);
324326
menuPanel.appendChild(
325-
createMenuButton(t('newExcel'), () => {
326-
onCreateNew('.xlsx');
327+
createMenuButton(t('newExcel'), async () => {
328+
await onCreateNew('.xlsx');
327329
}),
328330
);
329331
menuPanel.appendChild(
330-
createMenuButton(t('newPowerPoint'), () => {
331-
onCreateNew('.pptx');
332+
createMenuButton(t('newPowerPoint'), async () => {
333+
await onCreateNew('.pptx');
332334
}),
333335
);
334336

‎lib/loading.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ export const showLoading = (): { removeLoading: () => void } => {
1010
`;
1111

1212
const mask = document.createElement('div');
13-
mask.setAttribute('class', 'w-full h-full fixed top-0 left-0 bg-black/30 flex items-center justify-center z-[5]');
13+
mask.setAttribute('class', 'w-full h-full fixed top-0 left-0 bg-black/30 flex items-center justify-center');
1414
mask.style.cssText = `
1515
backdrop-filter: blur(2px);
16+
z-index: 10000;
1617
`;
1718
mask.appendChild(loading);
1819
document.body.appendChild(mask);

0 commit comments

Comments
 (0)