Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 2 commits intomainfrom14816-dropdown
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
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
6 changes: 6 additions & 0 deletionssite/src/components/SearchField/SearchField.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,12 @@ type Story = StoryObj<typeof SearchField>;

export const Empty: Story = {};

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

export const DefaultValue: Story = {
args: {
value: "owner:me",
Expand Down
12 changes: 11 additions & 1 deletionsite/src/components/SearchField/SearchField.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,19 +6,28 @@ import InputAdornment from "@mui/material/InputAdornment";
import TextField, { type TextFieldProps } from "@mui/material/TextField";
import Tooltip from "@mui/material/Tooltip";
import visuallyHidden from "@mui/utils/visuallyHidden";
importtype { FC } from "react";
import{ type FC, useEffect, useRef } from "react";

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

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

if (autoFocus) {
useEffect(() => {
inputRef.current?.focus();
});
}
return (
<TextField
// Specifying `minWidth` so that the text box can't shrink so much
Expand All@@ -27,6 +36,7 @@ export const SearchField: FC<SearchFieldProps> = ({
size="small"
value={value}
onChange={(e) => onChange(e.target.value)}
inputRef={inputRef}
InputProps={{
startAdornment: (
<InputAdornment position="start">
Expand Down
1 change: 1 addition & 0 deletionssite/src/pages/WorkspacesPage/WorkspacesButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,6 +69,7 @@ export const WorkspacesButton: FC<WorkspacesButtonProps> = ({
>
<MenuSearch
value={searchTerm}
autoFocus={true}
onChange={setSearchTerm}
placeholder="Type/select a workspace template"
aria-label="Template select for workspace"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp