Skip to content

Commit

Permalink
fix: type declarations error while building
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev committed Feb 20, 2024
1 parent 8a50b5f commit e64fbcf
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/react/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,18 @@ const Select = React.forwardRef(function Select(
}

const selectDefaultTitle = (defaultValue) => {
const selectElement = document.getElementById(id);
const title = defaultValue
? selectElement?.querySelector(`option[value=${defaultValue}]`)?.text
: selectElement?.options[selectElement?.selectedIndex]?.text;
setTitle(title);
const selectElement = document.getElementById(
id
) as HTMLSelectElement | null;
if (defaultValue) {
const defaultOption: HTMLOptionElement | null | undefined =
selectElement?.querySelector(`option[value=${defaultValue}]`);
setTitle(defaultOption?.text || '');
} else {
setTitle(
selectElement?.options[selectElement?.selectedIndex]?.text || ''
);
}
};
const handleFocus = (evt) => {
setIsFocused(evt.type === 'focus' ? true : false);
Expand Down

0 comments on commit e64fbcf

Please sign in to comment.