Skip to content

Commit

Permalink
updates from review
Browse files Browse the repository at this point in the history
  • Loading branch information
tlabaj committed Oct 23, 2023
1 parent 2539a2f commit dd22e01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions packages/react-core/src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ export enum TextInputReadOnlyVariant {
plain = 'plain'
}

interface TextinputExpandedObj {
export interface TextInputExpandedObj {
/** Flag to apply expanded styling. */
isExpanded: boolean;
/** Id of the element that the text input is controlling expansion of. */
ariaControls: string;
}

Expand All @@ -38,10 +40,10 @@ export interface TextInputProps
className?: string;
/** Flag to show if the text input is disabled. */
isDisabled?: boolean;
/** @deprecated Flag to apply expanded styling */
/** @deprecated Flag to apply expanded styling. expandedProps should now be used instead. */
isExpanded?: boolean;
/** Prop to apply expanded styling to the text input and link it toe the element it is controlling. This should be used when the input controls a menu and tha menu is expanded. */
expandedProps?: TextinputExpandedObj;
/** Prop to apply expanded styling to the text input and link it to the element it is controlling. This should be used when the input controls a menu and that menu is expandable. */
expandedProps?: TextInputExpandedObj;
/** Sets the input as readonly and determines the readonly styling. */
readOnlyVariant?: 'plain' | 'default';
/** Flag indicating whether the input is required */
Expand Down Expand Up @@ -201,7 +203,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
} = this.props;

const hasStatusIcon = ['success', 'error', 'warning'].includes(validated);
const ariaExpandedProps = expandedProps?.isExpanded
const ariaExpandedProps = expandedProps
? { 'aria-expanded': expandedProps?.isExpanded, 'aria-controls': expandedProps?.ariaControls, role: 'combobox' }
: {};

Expand All @@ -226,7 +228,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
type={type}
value={this.sanitizeInputValue(value)}
aria-invalid={props['aria-invalid'] ? props['aria-invalid'] : validated === ValidatedOptions.error}
{...(expandedProps?.isExpanded && { ...ariaExpandedProps })}
{...ariaExpandedProps}
required={isRequired}
disabled={isDisabled}
readOnly={!!readOnlyVariant || readOnly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: Text input
section: components
subsection: forms
cssPrefix: pf-v5-c-form-control
propComponents: ['TextInput']
propComponents: ['TextInput', 'TextInputExpandedObj']
---

import CalendarIcon from '@patternfly/react-icons/dist/esm/icons/calendar-icon';
Expand Down

0 comments on commit dd22e01

Please sign in to comment.