Skip to content

Commit

Permalink
fix(ui): make CoreSwitchInput reactive to state change. WF-81
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Oct 1, 2024
1 parent 1c26d26 commit 74a5124
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/ui/src/components/core/input/CoreSwitchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
>
<div
class="switch"
:class="{ on: toggleValue }"
:class="{ on: !!formValue }"
tabindex="0"
role="switch"
:aria-checked="toggleValue"
:aria-checked="!!formValue"
@click="handleToggle"
@keydown.enter.space.prevent="handleToggle"
>
Expand All @@ -29,7 +29,6 @@ import {
separatorColor,
cssClasses,
} from "@/renderer/sharedStyleFields";
import { onMounted } from "vue";
import BaseInputWrapper from "../base/BaseInputWrapper.vue";
import { ComponentPublicInstance } from "vue";
Expand Down Expand Up @@ -82,25 +81,16 @@ const { formValue, handleInput } = useFormValueBroker(
instancePath,
rootInstance,
);
const toggleValue = ref(false);
function handleToggle() {
toggleValue.value = !toggleValue.value;
handleInput(toggleValue.value, "wf-toggle");
handleInput(!formValue.value, "wf-toggle");
}
onMounted(() => {
toggleValue.value = !!formValue.value;
});
</script>

<style scoped>
@import "@/renderer/sharedStyles.css";
@import "@/renderer/colorTransformations.css";
.CoreSwitchInput {
}
.switch {
background: var(--separatorColor);
width: 34px;
Expand Down

0 comments on commit 74a5124

Please sign in to comment.