in Dataset/JS/ReactSelect/index.tsx [1696:1783]
renderInput() {
const {
isDisabled,
isSearchable,
inputId,
inputValue,
tabIndex,
form,
menuIsOpen,
required,
} = this.props;
const { Input } = this.getComponents();
const { inputIsHidden, ariaSelection } = this.state;
const { commonProps } = this;
const id = inputId || this.getElementId('input');
// aria attributes makes the JSX "noisy", separated for clarity
const ariaAttributes = {
'aria-autocomplete': 'list' as const,
'aria-expanded': menuIsOpen,
'aria-haspopup': true,
'aria-errormessage': this.props['aria-errormessage'],
'aria-invalid': this.props['aria-invalid'],
'aria-label': this.props['aria-label'],
'aria-labelledby': this.props['aria-labelledby'],
'aria-required': required,
role: 'combobox',
'aria-activedescendant': this.isAppleDevice
? undefined
: this.state.focusedOptionId || '',
...(menuIsOpen && {
'aria-controls': this.getElementId('listbox'),
}),
...(!isSearchable && {
'aria-readonly': true,
}),
...(this.hasValue()
? ariaSelection?.action === 'initial-input-focus' && {
'aria-describedby': this.getElementId('live-region'),
}
: {
'aria-describedby': this.getElementId('placeholder'),
}),
};
if (!isSearchable) {
// use a dummy input to maintain focus/blur functionality
return (
<DummyInput
id={id}
innerRef={this.getInputRef}
onBlur={this.onInputBlur}
onChange={noop}
onFocus={this.onInputFocus}
disabled={isDisabled}
tabIndex={tabIndex}
inputMode="none"
form={form}
value=""
{...ariaAttributes}
/>
);
}
return (
<Input
{...commonProps}
autoCapitalize="none"
autoComplete="off"
autoCorrect="off"
id={id}
innerRef={this.getInputRef}
isDisabled={isDisabled}
isHidden={inputIsHidden}
onBlur={this.onInputBlur}
onChange={this.handleInputChange}
onFocus={this.onInputFocus}
spellCheck="false"
tabIndex={tabIndex}
form={form}
type="text"
value={inputValue}
{...ariaAttributes}
/>
);
}