diff --git a/ts/components/ButtonDropdown.svelte b/ts/components/ButtonDropdown.svelte index 4e95fe673..8c18d92a3 100644 --- a/ts/components/ButtonDropdown.svelte +++ b/ts/components/ButtonDropdown.svelte @@ -8,7 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import ButtonToolbar from "./ButtonToolbar.svelte"; - export let id: string; + export let id: string | undefined = undefined; let className = ""; export { className as class }; diff --git a/ts/components/DropdownMenu.svelte b/ts/components/DropdownMenu.svelte index 8db932f4f..84423e7ea 100644 --- a/ts/components/DropdownMenu.svelte +++ b/ts/components/DropdownMenu.svelte @@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { setContext } from "svelte"; import { dropdownKey } from "./contextKeys"; - export let id: string; + export let id: string | undefined = undefined; setContext(dropdownKey, null); diff --git a/ts/components/WithDropdown.svelte b/ts/components/WithDropdown.svelte new file mode 100644 index 000000000..00ab70ed5 --- /dev/null +++ b/ts/components/WithDropdown.svelte @@ -0,0 +1,38 @@ + + + + + + diff --git a/ts/components/WithDropdownMenu.svelte b/ts/components/WithDropdownMenu.svelte deleted file mode 100644 index df09e20c4..000000000 --- a/ts/components/WithDropdownMenu.svelte +++ /dev/null @@ -1,49 +0,0 @@ - - - - diff --git a/ts/deckoptions/RevertButton.svelte b/ts/deckoptions/RevertButton.svelte index 2e5c66629..948982d57 100644 --- a/ts/deckoptions/RevertButton.svelte +++ b/ts/deckoptions/RevertButton.svelte @@ -4,7 +4,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - - createDropdown(event.detail.span)} - on:click={activateDropdown} - > - {@html revertIcon} - - - - +
+ (dropdown = createDropdown(event.detail.span))} on:click={() => { - revert(); - // Otherwise the menu won't close when the item is clicked - // TODO: investigate why this is necessary - activateDropdown(); + if (modified) { + dropdown.toggle(); + } }} > - {tr.deckConfigRevertButtonTooltip()}{@html revertIcon} - - - + {@html revertIcon} + + + + revert()} + > + {tr.deckConfigRevertButtonTooltip()}{@html revertIcon} + + +
+ diff --git a/ts/deckoptions/SaveButton.svelte b/ts/deckoptions/SaveButton.svelte index 52cda318b..a7cc91af4 100644 --- a/ts/deckoptions/SaveButton.svelte +++ b/ts/deckoptions/SaveButton.svelte @@ -6,6 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import * as tr from "lib/i18n"; import { createEventDispatcher } from "svelte"; import type { DeckOptionsState } from "./lib"; + import type Dropdown from "bootstrap/js/dist/dropdown"; import ButtonGroup from "components/ButtonGroup.svelte"; import ButtonGroupItem from "components/ButtonGroupItem.svelte"; @@ -14,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import DropdownMenu from "components/DropdownMenu.svelte"; import DropdownItem from "components/DropdownItem.svelte"; import DropdownDivider from "components/DropdownDivider.svelte"; - import WithDropdownMenu from "components/WithDropdownMenu.svelte"; + import WithDropdown from "components/WithDropdown.svelte"; import WithShortcut from "components/WithShortcut.svelte"; const dispatch = createEventDispatcher(); @@ -53,6 +54,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html commitEditing(); state.save(applyToChildDecks); } + + let dropdown: Dropdown; @@ -68,12 +71,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + createDropdown(event.detail.button)} - on:click={activateDropdown} + on:mount={(event) => (dropdown = createDropdown(event.detail.button))} + on:click={() => dropdown.toggle()} /> - + dispatch("add")} >{tr.deckConfigAddGroup()} @@ -91,6 +94,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {tr.deckConfigSaveToAllSubdecks()}
-
+ diff --git a/ts/editor/FormatBlockButtons.svelte b/ts/editor/FormatBlockButtons.svelte index e4e8fd80f..ee65cbb08 100644 --- a/ts/editor/FormatBlockButtons.svelte +++ b/ts/editor/FormatBlockButtons.svelte @@ -11,7 +11,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import IconButton from "components/IconButton.svelte"; import ButtonDropdown from "components/ButtonDropdown.svelte"; import Item from "components/Item.svelte"; - import WithDropdownMenu from "components/WithDropdownMenu.svelte"; + import WithDropdown from "components/WithDropdown.svelte"; import OnlyEditable from "./OnlyEditable.svelte"; import CommandIconButton from "./CommandIconButton.svelte"; @@ -63,7 +63,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + - + @@ -142,6 +142,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + diff --git a/ts/editor/TemplateButtons.svelte b/ts/editor/TemplateButtons.svelte index 198f94a87..42dd4164b 100644 --- a/ts/editor/TemplateButtons.svelte +++ b/ts/editor/TemplateButtons.svelte @@ -13,7 +13,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import IconButton from "components/IconButton.svelte"; import DropdownMenu from "components/DropdownMenu.svelte"; import DropdownItem from "components/DropdownItem.svelte"; - import WithDropdownMenu from "components/WithDropdownMenu.svelte"; + import WithDropdown from "components/WithDropdown.svelte"; import WithShortcut from "components/WithShortcut.svelte"; import WithContext from "components/WithContext.svelte"; import OnlyEditable from "./OnlyEditable.svelte"; @@ -88,7 +88,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - + - + - +