Skip to content

Commit

Permalink
Refactor #3092
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Aug 18, 2022
1 parent e18f15e commit 8da4b22
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions components/lib/dropdown/Dropdown.js
Expand Up @@ -614,15 +614,20 @@ export const Dropdown = React.memo(React.forwardRef((props, ref) => {
});

const createHiddenSelect = () => {
const placeHolderOption = <option value="">{props.placeholder}</option>;
let selectedValue = selectedOption ? getOptionValue(selectedOption) : "";
const option = selectedOption ? <option value={selectedValue}>{getOptionLabel(selectedOption)}</option> : null;
let option = { value: '', label: props.placeholder };

if (selectedOption) {
const optionValue = getOptionValue(selectedOption);
option = {
value: typeof optionValue === 'object' ? props.options.findIndex(o => o === optionValue) : optionValue,
label: getOptionLabel(selectedOption)
}
}

return (
<div className="p-hidden-accessible p-dropdown-hidden-select">
<select ref={inputRef} required={props.required} value={selectedValue} name={props.name} tabIndex={-1} aria-hidden="true" onChange={(e) => selectedValue = e.target.value}>
{placeHolderOption}
{option}
<select ref={inputRef} required={props.required} defaultValue={option.value} name={props.name} tabIndex={-1} aria-hidden="true">
<option value={option.value}>{option.label}</option>;
</select>
</div>
)
Expand Down

0 comments on commit 8da4b22

Please sign in to comment.