Skip to content

Commit bf6dd52

Browse files
Added option to ignore disabled for search bar (#12)
1 parent 8ede24a commit bf6dd52

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

components/Dropdown2.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ export default function Dropdown2(props: DropdownProps) {
162162
}}
163163
onFocus={(event) => event.target.select()}
164164
className="h-9 w-full text-sm border-gray-300 rounded-md placeholder-italic border text-gray-900 pr-8 pl-4 truncate placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100 disabled:opacity-50 disabled:cursor-not-allowed"
165-
disabled={isDisabled}
165+
disabled={isDisabled && !props.ignoreDisabledForSearch}
166166
placeholder="Type to search..." />
167167
<IconChevronDown
168-
className={`h-5 w-5 absolute right-0 mr-3 -mt-7 ${isDisabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
168+
className={`h-5 w-5 absolute right-0 mr-3 -mt-7 ${isDisabled && !props.ignoreDisabledForSearch ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
169169
aria-hidden="true"
170170
/>
171171
</div> : <>

types/dropdown.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* @useFillForIcons {boolean[], optional} - if true, the icon will be filled with the color of the option
4040
* @searchTextTyped {function} - returns the text typed in the search bar
4141
* @fontSizeClass {string} - The font size of the dropdown items
42+
* @ignoreDisabledForSearch {boolean} - If the search bar should ignore the disabled options
4243
*/
4344
export type DropdownProps = {
4445
buttonName?: string;
@@ -83,6 +84,7 @@ export type DropdownProps = {
8384
searchTextTyped?: (value: string) => void;
8485
fontSizeClass?: string;
8586
filteredOptions?: (option: string) => void;
87+
ignoreDisabledForSearch?: boolean;
8688
}
8789

8890
export type AppSelectionDropdownProps = {

0 commit comments

Comments
 (0)