diff --git a/src/applications/spell-source-class-assignments/SpellSourceClassAssignments.svelte b/src/applications/spell-source-class-assignments/SpellSourceClassAssignments.svelte index 6b5821958..1ca77d6ca 100644 --- a/src/applications/spell-source-class-assignments/SpellSourceClassAssignments.svelte +++ b/src/applications/spell-source-class-assignments/SpellSourceClassAssignments.svelte @@ -121,11 +121,11 @@ assignment.item.system.sourceClass === classColumn.key} + checked={selected} + on:change={(ev) => setItemSourceClass( assignment.item, - selected ? '' : classColumn.key, + ev.detail.currentTarget.checked ? classColumn.key : '', )} /> diff --git a/src/components/toggle/ConditionToggle.svelte b/src/components/toggle/ConditionToggle.svelte index 6afe0c9f9..e337c6aa2 100644 --- a/src/components/toggle/ConditionToggle.svelte +++ b/src/components/toggle/ConditionToggle.svelte @@ -21,7 +21,7 @@ switchOn = !condition.disabled; } - async function handleChange(originalValue: boolean) { + async function handleChange(newValue: boolean) { try { await FoundryAdapter.toggleCondition($context.actor, condition); } catch (e) { @@ -30,7 +30,7 @@ condition, state: switchOn, }); - switchOn = originalValue; + switchOn = !newValue; } } @@ -39,8 +39,8 @@ class="flex-row small-gap tidy-condition-toggle {switchOn ? 'active' : 'inactive'}" - bind:value={switchOn} - on:change={(ev) => handleChange(ev.detail.originalValue)} + bind:checked={switchOn} + on:change={(ev) => handleChange(ev.detail.currentTarget.checked)} title={condition.name} disabled={!$context.editable} data-uuid={condition.reference} diff --git a/src/components/toggle/PropertyToggle.svelte b/src/components/toggle/PropertyToggle.svelte index ff55108ff..ea80f8c79 100644 --- a/src/components/toggle/PropertyToggle.svelte +++ b/src/components/toggle/PropertyToggle.svelte @@ -17,18 +17,22 @@ switchOn = checked; } - async function handleChange(originalValue: boolean) { + async function handleChange(newValue: boolean) { try { - document.update({ - [field]: !originalValue, + const result = await document.update({ + [field]: newValue, }); + + if (!result) { + switchOn = !newValue; + } } catch (e) { error('An error occurred while toggling a property', false, e); debug('Property toggle error troubleshooting info', { - originalValue, + originalValue: !newValue, state: switchOn, }); - switchOn = originalValue; + switchOn = !newValue; } } @@ -37,8 +41,8 @@ class="flex-row small-gap tidy-property-toggle {switchOn ? 'active' : 'inactive'}" - bind:value={switchOn} - on:change={(ev) => handleChange(ev.detail.originalValue)} + bind:checked={switchOn} + on:change={(ev) => handleChange(ev.detail.currentTarget.checked)} {title} {disabled} > diff --git a/src/components/toggle/TidySwitch.svelte b/src/components/toggle/TidySwitch.svelte index 19663b170..d5f6aaf93 100644 --- a/src/components/toggle/TidySwitch.svelte +++ b/src/components/toggle/TidySwitch.svelte @@ -1,24 +1,15 @@ diff --git a/src/components/toggle/_toggles.scss b/src/components/toggle/_toggles.scss index 36d0da86c..1072ace31 100644 --- a/src/components/toggle/_toggles.scss +++ b/src/components/toggle/_toggles.scss @@ -54,6 +54,7 @@ .tidy-switch { display: flex; align-items: center; + cursor: pointer; --tidy-switch-scale-internal: var(--tidy-switch-scale, 1); --tidy-switch-thumb-transform-duration-internal: var( @@ -61,7 +62,7 @@ 0.3s ); - [role="switch"] { + [role='switch'] { width: calc(2.625rem * var(--tidy-switch-scale-internal)); height: calc(1.375rem * var(--tidy-switch-scale-internal)); position: relative; @@ -103,23 +104,19 @@ transition: transform var(--tidy-switch-thumb-transform-duration-internal); } - &[aria-checked='true'] { - &:not(.disabled) { - background-color: var(--t5e-primary-accent-color); - } + &:focus-visible { + outline: 0.0625rem solid var(--t5e-primary-accent-color); + } + } - &::before, - .thumb-icon { - transform: translateX( - calc(1.25rem * var(--tidy-switch-scale-internal)) - ); - transition: transform - var(--tidy-switch-thumb-transform-duration-internal); - } + &:has(input:checked) [role='switch'] { + &:not(.disabled) { + background-color: var(--t5e-primary-accent-color); } - &:focus-visible { - outline: 0.0625rem solid var(--t5e-primary-accent-color); + &::before, + .thumb-icon { + transform: translateX(calc(1.25rem * var(--tidy-switch-scale-internal))); } } } diff --git a/src/sheets/actor/SheetEditModeToggle.svelte b/src/sheets/actor/SheetEditModeToggle.svelte index c3de68318..388f70e8f 100644 --- a/src/sheets/actor/SheetEditModeToggle.svelte +++ b/src/sheets/actor/SheetEditModeToggle.svelte @@ -50,7 +50,7 @@ --tidy-switch-scale="1" --tidy-switch-thumb-transform-duration="0.15s" title={allowEdit ? unlockTitle : lockTitle} - value={allowEdit} + checked={allowEdit} thumbIconClass="{allowEdit ? 'fas fa-unlock' : 'fas fa-lock'} fa-fw" on:change={() => toggleLock()} > diff --git a/src/sheets/character/parts/FavoriteEffectsList.svelte b/src/sheets/character/parts/FavoriteEffectsList.svelte index ed935ba60..1bdd990ee 100644 --- a/src/sheets/character/parts/FavoriteEffectsList.svelte +++ b/src/sheets/character/parts/FavoriteEffectsList.svelte @@ -86,7 +86,7 @@ toggleEffect(effectContext)} /> diff --git a/src/sheets/shared/SheetHeaderEditModeToggle.svelte b/src/sheets/shared/SheetHeaderEditModeToggle.svelte index 777edb99e..847efb4ca 100644 --- a/src/sheets/shared/SheetHeaderEditModeToggle.svelte +++ b/src/sheets/shared/SheetHeaderEditModeToggle.svelte @@ -48,7 +48,7 @@ --tidy-switch-scale="1" --tidy-switch-thumb-transform-duration="0.15s" title={allowEdit ? unlockTitle : lockTitle} - value={allowEdit} + checked={allowEdit} thumbIconClass="{allowEdit ? 'fas fa-unlock' : 'fas fa-lock'} fa-fw" on:change={() => toggleLock()} >