Skip to content

fix: apply autofocus to workspace button search #16905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rename
  • Loading branch information
mtojek committed Mar 13, 2025
commit 51d27ccb1b6d02a4e875f0b378db01a0e32f0ee6
2 changes: 1 addition & 1 deletion site/src/components/SearchField/SearchField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Empty: Story = {};

export const Focused: Story = {
args: {
autoFocused: true,
autoFocus: true,
},
};

Expand Down
6 changes: 3 additions & 3 deletions site/src/components/SearchField/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import { type FC, useEffect, useRef } from "react";

export type SearchFieldProps = Omit<TextFieldProps, "onChange"> & {
onChange: (query: string) => void;
autoFocused?: boolean;
autoFocus?: boolean;
};

export const SearchField: FC<SearchFieldProps> = ({
value = "",
onChange,
autoFocused = false,
autoFocus = false,
InputProps,
...textFieldProps
}) => {
const theme = useTheme();
const inputRef = useRef<HTMLInputElement>(null);

if (autoFocused) {
if (autoFocus) {
useEffect(() => {
inputRef.current?.focus();
});
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacesPage/WorkspacesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const WorkspacesButton: FC<WorkspacesButtonProps> = ({
>
<MenuSearch
value={searchTerm}
autoFocused={true}
autoFocus={true}
onChange={setSearchTerm}
placeholder="Type/select a workspace template"
aria-label="Template select for workspace"
Expand Down
Loading