Skip to content

Commit

Permalink
fix: set readonly attribute on inputs (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS authored Aug 23, 2024
1 parent cb91068 commit a34501d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/components/DateField/hooks/useDateFieldProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export function useDateFieldProps<T = DateTime>(
});

function syncSelectionFromDOM() {
if (state.readOnly) {
setSelectedSections(-1);
return;
}
state.focusSectionInPosition(inputRef.current?.selectionStart ?? 0);
setInnerState({});
}
Expand Down Expand Up @@ -192,6 +188,7 @@ export function useDateFieldProps<T = DateTime>(
'aria-describedby': props['aria-describedby'] || undefined,
'aria-details': props['aria-details'] || undefined,
'aria-disabled': state.disabled || undefined,
readOnly: state.readOnly,
inputMode,
onClick() {
syncSelectionFromDOM();
Expand Down
1 change: 0 additions & 1 deletion src/components/RangeDatePicker/RangeDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export function RangeDatePicker({className, ...props}: RangeDatePickerProps) {
<TextInput
{...fieldProps}
className={b('field')}
hasClear={fieldProps.hasClear}
endContent={
<React.Fragment>
{!isOnlyTime && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function useRelativeDateFieldProps(
'aria-describedby': props['aria-describedby'] || undefined,
'aria-details': props['aria-details'] || undefined,
'aria-disabled': state.disabled || undefined,
readOnly: state.readOnly,
},
},
calendarProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export function RelativeRangeDatePicker(props: RelativeRangeDatePickerProps) {
role: 'combobox',
'aria-expanded': open,
disabled: isMobile,
readOnly: props.readOnly,
className: b('input', {mobile: isMobile}),
onClick: () => {
if (props.disabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function Zones(props: ZonesProps) {
const size = props.isMobile ? 'xl' : props.size;
return (
<Select
disabled={props.disabled}
value={[timeZone]}
options={zones}
size={size}
Expand All @@ -82,6 +83,7 @@ export function Zones(props: ZonesProps) {
width="max"
pin="clear-clear"
size={size}
disabled={props.disabled}
extraProps={{
'aria-haspopup': 'listbox',
'aria-expanded': controlProps.open,
Expand Down

0 comments on commit a34501d

Please sign in to comment.