Don't set values on ref prop

This commit is contained in:
thepaperpilot 2022-12-24 08:38:36 -06:00
parent cc35ee0a42
commit 9dd359ef6c
2 changed files with 12 additions and 9 deletions

View file

@ -13,6 +13,7 @@
v-if="layerKeys.includes(tab)" v-if="layerKeys.includes(tab)"
v-bind="gatherLayerProps(layers[tab]!)" v-bind="gatherLayerProps(layers[tab]!)"
:index="index" :index="index"
@set-minimized="value => (layers[tab]!.minimized.value = value)"
/> />
<component :is="tab" :index="index" v-else /> <component :is="tab" :index="index" v-else />
</div> </div>

View file

@ -2,7 +2,11 @@
<div class="layer-container" :style="{ '--layer-color': unref(color) }"> <div class="layer-container" :style="{ '--layer-color': unref(color) }">
<button v-if="showGoBack" class="goBack" @click="goBack"></button> <button v-if="showGoBack" class="goBack" @click="goBack"></button>
<button class="layer-tab minimized" v-if="unref(minimized)" @click="setMinimized(false)"> <button
class="layer-tab minimized"
v-if="unref(minimized)"
@click="$emit('setMinimized', false)"
>
<component v-if="minimizedComponent" :is="minimizedComponent" /> <component v-if="minimizedComponent" :is="minimizedComponent" />
<div v-else>{{ unref(name) }}</div> <div v-else>{{ unref(name) }}</div>
</button> </button>
@ -12,7 +16,9 @@
</Context> </Context>
</div> </div>
<button v-if="unref(minimizable)" class="minimize" @click="setMinimized(true)"></button> <button v-if="unref(minimizable)" class="minimize" @click="$emit('setMinimized', true)">
</button>
</div> </div>
</template> </template>
@ -40,7 +46,7 @@ export default defineComponent({
}, },
minimizedDisplay: processedPropType<CoercableComponent>(Object, String, Function), minimizedDisplay: processedPropType<CoercableComponent>(Object, String, Function),
minimized: { minimized: {
type: Object as PropType<Persistent<boolean>>, type: Object as PropType<Ref<boolean>>,
required: true required: true
}, },
name: { name: {
@ -54,6 +60,7 @@ export default defineComponent({
required: true required: true
} }
}, },
emits: ["setMinimized"],
setup(props) { setup(props) {
const { display, index, minimized, minimizedDisplay } = toRefs(props); const { display, index, minimized, minimizedDisplay } = toRefs(props);
@ -67,10 +74,6 @@ export default defineComponent({
player.tabs.splice(unref(props.index), 1); player.tabs.splice(unref(props.index), 1);
} }
function setMinimized(min: boolean) {
minimized.value = min;
}
function updateNodes(nodes: Record<string, FeatureNode | undefined>) { function updateNodes(nodes: Record<string, FeatureNode | undefined>) {
props.nodes.value = nodes; props.nodes.value = nodes;
} }
@ -81,8 +84,7 @@ export default defineComponent({
showGoBack, showGoBack,
updateNodes, updateNodes,
unref, unref,
goBack, goBack
setMinimized
}; };
} }
}); });