WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -130,12 +130,18 @@ const componentProps = computed(() => {
130130 const filteredProps: typeof propConfig = {}
131131
132132 Object .entries (propConfig ).forEach (([propName , config ]) => {
133- const isVisible = config .condition ? config .condition (currentProps ) : true
134- if (! isVisible ) return
133+ const showProp = config .condition ? config .condition (currentProps ) : true
134+ if (! showProp ) {
135+ props .block ?.removeProp (propName )
136+ return
137+ }
135138
136139 if (props .block ?.componentProps [propName ] === undefined ) {
137140 const defaultValue = typeof config .default === " function" ? config .default () : config .default
138141 config .modelValue = defaultValue
142+ if (defaultValue !== undefined ) {
143+ props .block ?.setProp (propName , defaultValue )
144+ }
139145 } else {
140146 config .modelValue = props .block .componentProps [propName ]
141147 }
Original file line number Diff line number Diff line change @@ -367,7 +367,7 @@ export const COMPONENTS: FrappeUIComponents = {
367367 options : {
368368 required : false ,
369369 type : Array ,
370- default : [ "John Doe" , "Jane Doe" ] ,
370+ default : ( ) => [ "John Doe" , "Jane Doe" ] ,
371371 condition : ( state : Record < string , any > ) => state . type === "select" || state . type === "autocomplete"
372372 }
373373 } ,
Original file line number Diff line number Diff line change @@ -551,6 +551,10 @@ class Block implements BlockOptions {
551551 this . componentProps [ propName ] = value
552552 }
553553
554+ removeProp ( propName : string ) {
555+ delete this . componentProps [ propName ]
556+ }
557+
554558 // component slots
555559 initializeSlots ( ) {
556560 Object . entries ( this . componentSlots ) . forEach ( ( [ slotName , slot ] ) => {
You can’t perform that action at this time.
0 commit comments