Skip to content

Commit

Permalink
add initial focus to search input
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Buczacka authored and Walter Buczacka committed Apr 19, 2024
1 parent 72af363 commit 3f68bfe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/cms/components/fields/ProfileSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ProfileTile from "./ProfileTile";
import groupMeta from "../../utils/groupMeta";
import stripHTML from "../../utils/formatters/stripHTML";
import NonIdealState from "../../../core/components/NonIdealState";
import {useFocus} from "./useFocus";

function DimensionFilters({
activeProfile,
Expand Down Expand Up @@ -277,6 +278,9 @@ export function ProfileSearch({

const [debouncedQuery] = useDebouncedValue(query, 400);
const profiles = useCMSProfiles();
const [inputRef, setInputFocus] = useFocus();

React.useLayoutEffect(() => setInputFocus(), [setInputFocus]);

const ignoredTermsRegex = ignoredTerms && ignoredTerms.length > 0
? new RegExp(`\\b(${ignoredTerms.join("|")})\\b`, "ig")
Expand Down Expand Up @@ -409,7 +413,7 @@ export function ProfileSearch({
</Text>
</Text>
<TextInput
ref={textInput}
ref={inputRef}
className="cp-input"
icon={<IconSearch />}
size="xl"
Expand Down

0 comments on commit 3f68bfe

Please sign in to comment.