-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Feature : allow controls with DataForm to be set as disabled
#74262
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
base: trunk
Are you sure you want to change the base?
Changes from 4 commits
dad0c81
c083633
0aad89e
6e410b2
bb10b21
6fb11f1
c2023a8
f80dbf2
49772ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,6 +256,7 @@ function CalendarDateControl< Item >( { | |
| onChange, | ||
| hideLabelFromVision, | ||
| validity, | ||
| config, | ||
| }: DataFormControlProps< Item > ) { | ||
| const { | ||
| id, | ||
|
|
@@ -265,6 +266,7 @@ function CalendarDateControl< Item >( { | |
| isValid, | ||
| format: fieldFormat, | ||
| } = field; | ||
| const { disabled = false } = config || {}; | ||
| const [ selectedPresetId, setSelectedPresetId ] = useState< string | null >( | ||
| null | ||
| ); | ||
|
|
@@ -368,6 +370,8 @@ function CalendarDateControl< Item >( { | |
| variant="tertiary" | ||
| isPressed={ isSelected } | ||
| size="small" | ||
| disabled={ disabled } | ||
| accessibleWhenDisabled={ false } | ||
| onClick={ () => | ||
| handlePresetClick( preset ) | ||
| } | ||
|
|
@@ -381,7 +385,7 @@ function CalendarDateControl< Item >( { | |
| variant="tertiary" | ||
| isPressed={ ! selectedPresetId } | ||
| size="small" | ||
| disabled={ !! selectedPresetId } | ||
| disabled={ !! selectedPresetId || disabled } | ||
| accessibleWhenDisabled={ false } | ||
| > | ||
| { __( 'Custom' ) } | ||
|
|
@@ -398,6 +402,7 @@ function CalendarDateControl< Item >( { | |
| value={ value } | ||
| onChange={ handleManualDateChange } | ||
| required={ !! field.isValid?.required } | ||
| disabled={ disabled } | ||
| /> | ||
|
|
||
| { /* Calendar widget */ } | ||
|
|
@@ -411,6 +416,7 @@ function CalendarDateControl< Item >( { | |
| onMonthChange={ setCalendarMonth } | ||
| timeZone={ timezoneString || undefined } | ||
| weekStartsOn={ weekStartsOn } | ||
| disabled={ disabled } | ||
| /> | ||
| </Stack> | ||
| </BaseControl> | ||
|
|
@@ -424,8 +430,10 @@ function CalendarDateRangeControl< Item >( { | |
| onChange, | ||
| hideLabelFromVision, | ||
| validity, | ||
| config, | ||
| }: DataFormControlProps< Item > ) { | ||
| const { id, label, getValue, setValue, format: fieldFormat } = field; | ||
| const { disabled = false } = config || {}; | ||
| let value: DateRange; | ||
| const fieldValue = getValue( { item: data } ); | ||
| if ( | ||
|
|
@@ -576,6 +584,8 @@ function CalendarDateRangeControl< Item >( { | |
| variant="tertiary" | ||
| isPressed={ isSelected } | ||
| size="small" | ||
| disabled={ disabled } | ||
| accessibleWhenDisabled={ false } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was very surprised by this value for @jorgefilipecosta it seems all 3 occurrences are from you. Was that intentional for some reason?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yah it was intentional, if the custom button is disabled I don't see any value in including in on the tab sequence/ screen readers tree, it seems better to not have accessible, it does not adds any value.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm.. For
For this PR, maybe it's similar to the range-control example you shared. |
||
| onClick={ () => | ||
| handlePresetClick( preset ) | ||
| } | ||
|
|
@@ -590,7 +600,7 @@ function CalendarDateRangeControl< Item >( { | |
| isPressed={ ! selectedPresetId } | ||
| size="small" | ||
| accessibleWhenDisabled={ false } | ||
| disabled={ !! selectedPresetId } | ||
| disabled={ !! selectedPresetId || disabled } | ||
| > | ||
| { __( 'Custom' ) } | ||
| </Button> | ||
|
|
@@ -614,6 +624,7 @@ function CalendarDateRangeControl< Item >( { | |
| handleManualDateChange( 'from', newValue ) | ||
| } | ||
| required={ !! field.isValid?.required } | ||
| disabled={ disabled } | ||
| /> | ||
| <InputControl | ||
| __next40pxDefaultSize | ||
|
|
@@ -626,6 +637,7 @@ function CalendarDateRangeControl< Item >( { | |
| handleManualDateChange( 'to', newValue ) | ||
| } | ||
| required={ !! field.isValid?.required } | ||
| disabled={ disabled } | ||
| /> | ||
| </Stack> | ||
|
|
||
|
|
@@ -637,6 +649,7 @@ function CalendarDateRangeControl< Item >( { | |
| onMonthChange={ setCalendarMonth } | ||
| timeZone={ timezone.string || undefined } | ||
| weekStartsOn={ weekStartsOn } | ||
| disabled={ disabled } | ||
| /> | ||
| </Stack> | ||
| </BaseControl> | ||
|
|
@@ -651,6 +664,7 @@ export default function DateControl< Item >( { | |
| hideLabelFromVision, | ||
| operator, | ||
| validity, | ||
| config, | ||
| }: DataFormControlProps< Item > ) { | ||
| if ( operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER ) { | ||
| return ( | ||
|
|
@@ -661,6 +675,7 @@ export default function DateControl< Item >( { | |
| onChange={ onChange } | ||
| hideLabelFromVision={ hideLabelFromVision } | ||
| operator={ operator } | ||
| config={ config } | ||
| /> | ||
| ); | ||
| } | ||
|
|
@@ -673,6 +688,7 @@ export default function DateControl< Item >( { | |
| onChange={ onChange } | ||
| hideLabelFromVision={ hideLabelFromVision } | ||
| validity={ validity } | ||
| config={ config } | ||
| /> | ||
| ); | ||
| } | ||
|
|
@@ -684,6 +700,7 @@ export default function DateControl< Item >( { | |
| onChange={ onChange } | ||
| hideLabelFromVision={ hideLabelFromVision } | ||
| validity={ validity } | ||
| config={ config } | ||
| /> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change necessary? Perhaps this PR needs a rebase from
trunk?