Skip to content

Commit

Permalink
Merge branch 'develop' into issue/10525/user-avatat-delete-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rajku-dev authored Feb 19, 2025
2 parents f7dcfc7 + fa57650 commit 0dce732
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Common/SearchByMultipleFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface SearchByMultipleFieldsProps {
clearSearch?: { value: boolean; params?: string[] };
enableOptionButtons?: boolean;
onFieldChange?: (options: SearchOption) => void;
autoFocus?: boolean;
}

const KeyboardShortcutHint = ({ open }: { open: boolean }) => {
Expand Down Expand Up @@ -90,6 +91,7 @@ const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
clearSearch,
onFieldChange,
enableOptionButtons = true,
autoFocus = false,
}) => {
const { t } = useTranslation();
const [selectedOptionIndex, setSelectedOptionIndex] =
Expand Down Expand Up @@ -175,12 +177,6 @@ const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
return () => document.removeEventListener("keydown", handleKeyDown);
}, [focusedIndex, open, handleOptionChange, options]);

useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, [selectedOptionIndex]);

useEffect(() => {
if (selectedOption.value !== searchValue) {
onSearch(selectedOption.key, searchValue);
Expand Down Expand Up @@ -224,6 +220,12 @@ const SearchByMultipleFields: React.FC<SearchByMultipleFieldsProps> = ({
}
}, [selectedOption, searchValue, t, inputClassName, open]);

useEffect(() => {
if (autoFocus) {
inputRef.current?.focus();
}
}, [autoFocus, open, selectedOptionIndex]);

return (
<div
className={cn(
Expand Down
1 change: 1 addition & 0 deletions src/components/Resource/ResourceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export default function ResourceList({ facilityId }: { facilityId: string }) {
})
}
className="w-full border-none shadow-none"
autoFocus
/>
</div>
</PopoverContent>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Encounters/EncounterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export function EncounterList({
onFieldChange={handleFieldChange}
onSearch={handleSearch}
className="w-full border-none shadow-none"
autoFocus
/>
</div>
</PopoverContent>
Expand Down

0 comments on commit 0dce732

Please sign in to comment.