File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed
Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @sjsf/form " : patch
3+ ---
4+
5+ Disable ` clear ` and ` clearEdit ` action buttons for read-only fields and disabled forms
Original file line number Diff line number Diff line change 55 import {
66 getComponent ,
77 getDefaultFieldState ,
8+ isDisabled ,
89 retrieveTranslate ,
910 Text ,
1011 type Config ,
3536 <Button
3637 type =" clear-edit-action"
3738 {config }
38- disabled ={false }
39+ disabled ={config . schema . readOnly || isDisabled ( ctx ) }
3940 {errors }
4041 onclick ={() => {
4142 valueRef .current = isNil (valueRef .current )
42- ? (getDefaultFieldState (ctx , config .schema , undefined ) ??
43- getDefaultValueForType (getSimpleSchemaType (config .schema )))
43+ ? (getDefaultFieldState (ctx , {
44+ schema: config .schema ,
45+ formData: undefined ,
46+ includeUndefinedValues: " excludeObjectChildren" ,
47+ }) ?? getDefaultValueForType (getSimpleSchemaType (config .schema )))
4448 : undefined ;
4549 }}
4650 >
Original file line number Diff line number Diff line change 22 import type { Ref } from " @/lib/svelte.svelte.js" ;
33 import {
44 getComponent ,
5+ isDisabled ,
56 retrieveTranslate ,
67 Text ,
78 type Config ,
3132 <Button
3233 type =" clear-action"
3334 {config }
34- disabled ={false }
35+ disabled ={config . schema . readOnly || isDisabled ( ctx ) }
3536 {errors }
3637 onclick ={() => {
3738 valueRef .current = undefined ;
Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ export function assignProps<O>(options: O) {
144144 return < T extends object > ( props : T ) => Object . assign ( props , options ) ;
145145}
146146
147+ /**
148+ * @query
149+ */
147150export function isDisabled < T > (
148151 ctx : FormState < T > ,
149152 attributes ?: Partial < Nullable < Disabled > >
You can’t perform that action at this time.
0 commit comments