Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: fixed inconsistent in bbswitch (#650)

Luke Zhou065b91e1dd72
diff --git a/frontend/src/bbkit/BBSwitch.vue b/frontend/src/bbkit/BBSwitch.vue
index efe862764a..48b1855ed8 100644
--- a/frontend/src/bbkit/BBSwitch.vue
+++ b/frontend/src/bbkit/BBSwitch.vue
@@ -3,13 +3,17 @@
<button
type="button"
class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent disabled:cursor-not-allowed select-none"
- :class="on ? 'bg-accent disabled:bg-accent-disabled' : 'bg-gray-200'"
+ :class="
+ state.dirtyOn ? 'bg-accent disabled:bg-accent-disabled' : 'bg-gray-200'
+ "
:disabled="disabled"
aria-pressed="false"
@click.prevent="
() => {
- on = !on;
- $emit('toggle', on);
+ state.dirtyOn = !state.dirtyOn;
+ $emit('toggle', state.dirtyOn);
+
+ state.dirtyOn = props.value;
}
"
>
@@ -18,7 +22,7 @@
<span
aria-hidden="true"
class="pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"
- :class="on ? 'translate-x-5' : 'translate-x-0'"
+ :class="state.dirtyOn ? 'translate-x-5' : 'translate-x-0'"
></span>
</button>
<span
@@ -32,7 +36,7 @@
</template>
<script lang="ts" setup>
-import { ref, watch, defineProps, defineEmits, withDefaults } from "vue";
+import { watch, defineProps, defineEmits, withDefaults, reactive } from "vue";
const props = withDefaults(
defineProps<{
@@ -48,15 +52,17 @@ const props = withDefaults(
);
defineEmits<{
- (event: "toggle", on: boolean): void;
+ (event: "toggle", dirtyOn: boolean): void;
}>();
-const on = ref(props.value);
+const state = reactive({
+ dirtyOn: props.value,
+});
watch(
() => props.value,
(cur) => {
- on.value = cur;
+ state.dirtyOn = cur;
}
);
</script>