Skip to content

Commit

Permalink
fix: do not open creature suggester immediately when editing a creature
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed May 3, 2023
1 parent 6a866f6 commit 4340370
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/tracker/ui/create/Create.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
);
});
};
let nameInput: HTMLInputElement;
let nameInput: HTMLInputElement, displayNameInput: HTMLInputElement;
let modal: SRDMonsterSuggestionModal;
onMount(() => {
const createModal = () => {
modal = new SRDMonsterSuggestionModal(plugin, nameInput);
modal.onClose = async () => {
if (modal.creature) {
Expand All @@ -136,6 +136,16 @@
);
}
};
};
onMount(() => {
if (isEditing) {
setImmediate(() => {
displayNameInput.focus();
createModal();
});
} else {
createModal();
}
});
const hideToggle = (div: HTMLDivElement) => {
new ToggleComponent(div)
Expand Down Expand Up @@ -163,7 +173,7 @@
bind:this={nameInput}
bind:value={creature.name}
on:focus={function () {
modal.open();
if (modal) modal.open();
}}
id="add-name"
type="text"
Expand All @@ -175,6 +185,7 @@
<label for="add-display">Display Name</label>
<input
bind:value={creature.display}
bind:this={displayNameInput}
id="add-display"
type="text"
name="display"
Expand Down

0 comments on commit 4340370

Please sign in to comment.