Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/field/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function addCheckboxAttributes(inputType: string, field: Field, schema: NonBoole
field.checkboxValue = schema.const

// However, if the schema type is boolean, we should set the valid value as `true`
if (schema.type === 'boolean') {
if (Array.isArray(schema.type) ? schema.type.includes('boolean') : schema.type === 'boolean') {
field.checkboxValue = true
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,18 @@ describe('fields', () => {
expect(field?.checkboxValue).toBe(true)
})

it('uses checkbox input for boolean/null type array with boolean const value', () => {
const booleanNullSchema = {
'x-jsf-presentation': {
inputType: 'checkbox' as const,
},
'type': ['boolean', 'null'],
}
const field = buildFieldSchema(booleanNullSchema, 'test')
expect(field?.inputType).toBe('checkbox')
expect(field?.checkboxValue).toBe(true)
})

// Skipping these tests until we have group-array support
describe('array type inputs', () => {
it('uses group-array when items has properties', () => {
Expand Down