Replace promise with await in MenuList.vue

This commit is contained in:
Keavon Chambers 2021-08-12 19:25:57 -07:00
parent 3a11bf02f8
commit db2fe322c3
1 changed files with 14 additions and 14 deletions

View File

@ -215,25 +215,25 @@ const MenuList = defineComponent({
const floatingMenu = this.$refs.floatingMenu as typeof FloatingMenu; const floatingMenu = this.$refs.floatingMenu as typeof FloatingMenu;
return Boolean(floatingMenu && floatingMenu.isOpen()); return Boolean(floatingMenu && floatingMenu.isOpen());
}, },
measureAndReportWidth() { async measureAndReportWidth() {
// API is experimental but supported in all browsers - https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet // API is experimental but supported in all browsers - https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
(document as any).fonts.ready.then(() => { await (document as any).fonts.ready;
const floatingMenu = this.$refs.floatingMenu as typeof FloatingMenu;
// Save open/closed state before forcing open, if necessary, for measurement const floatingMenu = this.$refs.floatingMenu as typeof FloatingMenu;
const initiallyOpen = floatingMenu.isOpen();
if (!initiallyOpen) floatingMenu.setOpen();
floatingMenu.disableMinWidth((initialMinWidth: string) => { // Save open/closed state before forcing open, if necessary, for measurement
floatingMenu.getWidth((width: number) => { const initiallyOpen = floatingMenu.isOpen();
floatingMenu.enableMinWidth(initialMinWidth); if (!initiallyOpen) floatingMenu.setOpen();
// Restore open/closed state if it was forced open for measurement floatingMenu.disableMinWidth((initialMinWidth: string) => {
if (!initiallyOpen) floatingMenu.setClosed(); floatingMenu.getWidth((width: number) => {
floatingMenu.enableMinWidth(initialMinWidth);
this.$emit("width-changed", width); // Restore open/closed state if it was forced open for measurement
}); if (!initiallyOpen) floatingMenu.setClosed();
this.$emit("width-changed", width);
}); });
}); });
}, },