Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(application-system): Fix checkbox half width and third width layout #17305

Merged
merged 2 commits into from
Dec 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const fieldsRepeaterSubsection = buildSubSection({
id: 'fieldsRepeater',
title: 'Fields Repeater',
formTitle: 'Title for each form',
width: 'half',
width: 'full',
fields: {
input: {
component: 'input',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ export const Item = ({
const { setValue, control, clearErrors } = useFormContext()
const prevWatchedValuesRef = useRef<string | (string | undefined)[]>()

const getSpan = (component: string, width: string) => {
if (component !== 'radio' && component !== 'checkbox') {
if (width === 'half') {
return '1/2'
}
if (width === 'third') {
return '1/3'
}
return '1/1'
}
return '1/1'
}

const {
component,
id: itemId,
Expand All @@ -61,9 +74,8 @@ export const Item = ({
defaultValue,
...props
} = item
const isHalfColumn = component !== 'radio' && width === 'half'
const isThirdColumn = component !== 'radio' && width === 'third'
const span = isHalfColumn ? '1/2' : isThirdColumn ? '1/3' : '1/1'

const span = getSpan(component, width)
const Component = componentMapper[component]
const id = `${dataId}[${index}].${itemId}`
const activeValues = index >= 0 && values ? values[index] : undefined
Expand Down Expand Up @@ -203,7 +215,7 @@ export const Item = ({
label={formatText(label, application, formatMessage)}
options={translatedOptions}
placeholder={formatText(placeholder, application, formatMessage)}
split={width === 'half' ? '1/2' : '1/1'}
split={width === 'half' ? '1/2' : width === 'third' ? '1/3' : '1/1'}
error={getFieldError(itemId)}
control={control}
readOnly={Readonly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ export const Item = ({
const { setValue, control, clearErrors } = useFormContext()
const prevWatchedValuesRef = useRef<string | (string | undefined)[]>()

const getSpan = (component: string, width: string) => {
if (component !== 'radio' && component !== 'checkbox') {
if (width === 'half') {
return '1/2'
}
if (width === 'third') {
return '1/3'
}
return '1/1'
}
return '1/1'
}

const {
component,
id: itemId,
Expand All @@ -61,9 +74,8 @@ export const Item = ({
defaultValue,
...props
} = item
const isHalfColumn = component !== 'radio' && width === 'half'
const isThirdColumn = component !== 'radio' && width === 'third'
const span = isHalfColumn ? '1/2' : isThirdColumn ? '1/3' : '1/1'

const span = getSpan(component, width)
const Component = componentMapper[component]
const id = `${dataId}[${activeIndex}].${itemId}`
const activeValues =
Expand Down Expand Up @@ -203,7 +215,7 @@ export const Item = ({
label={formatText(label, application, formatMessage)}
options={translatedOptions}
placeholder={formatText(placeholder, application, formatMessage)}
split={width === 'half' ? '1/2' : '1/1'}
split={width === 'half' ? '1/2' : width === 'third' ? '1/3' : '1/1'}
error={getFieldError(itemId)}
control={control}
readOnly={Readonly}
Expand Down
Loading