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
6 changes: 6 additions & 0 deletions packages/eui/changelogs/upcoming/8271.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Changed `EuiFieldText` styles to prioritize `disabled` styling over `readonly`.

**Bug fixes**

- Fixed `disabled` behavior of `EuiFieldText` to prevent input changes.

Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const euiFieldTextStyles = (euiThemeContext: UseEuiTheme) => {
${formStyles.focus}
}

&:disabled {
${formStyles.disabled}
}

&[readOnly] {
${formStyles.readOnly}
}

&:disabled {
${formStyles.disabled}
}

&:autofill {
${formStyles.autoFill}
}
Expand Down
11 changes: 9 additions & 2 deletions packages/eui/src/components/form/field_text/field_text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export type EuiFieldTextProps = InputHTMLAttributes<HTMLInputElement> &
*/
fullWidth?: boolean;
isLoading?: boolean;
/**
* Prevents user from changing input.
*
* Defaults to the value of `disabled` unless explicity defined otherwise.
*/
readOnly?: boolean;
inputRef?: Ref<HTMLInputElement>;

Expand Down Expand Up @@ -74,7 +79,8 @@ export const EuiFieldText: FunctionComponent<EuiFieldTextProps> = (props) => {
compressed,
prepend,
append,
readOnly,
disabled,
readOnly = disabled, // sync to prevent onChange unless explicitly defined
controlOnly,
...rest
} = props;
Expand Down Expand Up @@ -103,6 +109,7 @@ export const EuiFieldText: FunctionComponent<EuiFieldTextProps> = (props) => {
css={cssStyles}
value={value}
ref={inputRef}
disabled={disabled}
readOnly={readOnly}
{...rest}
/>
Expand All @@ -117,8 +124,8 @@ export const EuiFieldText: FunctionComponent<EuiFieldTextProps> = (props) => {
fullWidth={fullWidth}
isLoading={isLoading}
isInvalid={isInvalid}
isDisabled={rest.disabled}
compressed={compressed}
isDisabled={disabled}
readOnly={readOnly}
prepend={prepend}
append={append}
Expand Down
Loading