Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

fix: resolve mobile keyboard fluctuation during search #9248

Merged
merged 16 commits into from
Nov 19, 2023
Merged
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
Next Next commit
fix: replace useEffect with useLayoutEffect hook
  • Loading branch information
badrivlog committed Oct 29, 2023
commit 51d74c0bb87d562475d4aba09661439cdc1638f0
10 changes: 8 additions & 2 deletions pages/search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { useEffect, useState, useCallback, useRef } from "react";
import {
useEffect,
useState,
useCallback,
useRef,
useLayoutEffect,
} from "react";
import { useRouter } from "next/router";
import UserHorizontal from "@components/user/UserHorizontal";
import Alert from "@components/Alert";
Expand Down Expand Up @@ -93,7 +99,7 @@ export default function Search({
setNotFound(`${username} not found`);
}
}, [username]);
useEffect(() => {
useLayoutEffect(() => {
if (searchInputRef.current) {
searchInputRef.current.focus();
}
Expand Down