clear highlight state as part of component select

This commit is contained in:
Peter Clement 2025-01-15 15:54:40 +00:00
parent 8763f5251c
commit 094881e807
3 changed files with 9 additions and 18 deletions

View File

@ -5,7 +5,6 @@
runtimeToReadableBinding, runtimeToReadableBinding,
} from "@/dataBinding" } from "@/dataBinding"
import { builderStore } from "@/stores/builder" import { builderStore } from "@/stores/builder"
import { onDestroy } from "svelte"
export let label = "" export let label = ""
export let labelHidden = false export let labelHidden = false
@ -79,12 +78,6 @@
? defaultValue ? defaultValue
: enriched : enriched
} }
onDestroy(() => {
if (highlightedSettings) {
builderStore.highlightSetting(null)
}
})
</script> </script>
<div <div

View File

@ -1,5 +1,4 @@
<script lang="ts"> <script lang="ts">
import { onDestroy } from "svelte"
import { ActionButton, Modal, ModalContent, Combobox } from "@budibase/bbui" import { ActionButton, Modal, ModalContent, Combobox } from "@budibase/bbui"
import { getAllStateVariables } from "@/dataBinding" import { getAllStateVariables } from "@/dataBinding"
import { import {
@ -94,17 +93,10 @@
}) { }) {
componentStore.select(component.id) componentStore.select(component.id)
// Delay highlighting until after component selection and re-render (i know this is disgusting)
setTimeout(() => {
component.settings.forEach(setting => { component.settings.forEach(setting => {
builderStore.highlightSetting(setting) builderStore.highlightSetting(setting)
}) })
}, 100)
} }
onDestroy(() => {
builderStore.highlightSetting(undefined)
})
</script> </script>
<ActionButton on:click={modal.show}>State</ActionButton> <ActionButton on:click={modal.show}>State</ActionButton>

View File

@ -20,6 +20,7 @@ import {
previewStore, previewStore,
tables, tables,
componentTreeNodesStore, componentTreeNodesStore,
builderStore,
} from "@/stores/builder" } from "@/stores/builder"
import { buildFormSchema, getSchemaForDatasource } from "@/dataBinding" import { buildFormSchema, getSchemaForDatasource } from "@/dataBinding"
import { import {
@ -716,6 +717,11 @@ export class ComponentStore extends BudiStore<ComponentState> {
* @param {string} componentId * @param {string} componentId
*/ */
select(componentId: string) { select(componentId: string) {
builderStore.update(state => {
state.highlightedSettings = null
return state
})
this.update(state => { this.update(state => {
state.selectedComponentId = componentId state.selectedComponentId = componentId
return state return state