chore: [app dir bootstrapping 3] check nullability in AppListCard (#11980)
parent
ce64c494f4
commit
3679854c43
|
@ -60,14 +60,18 @@ export default function AppListCard(props: AppListCardProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldHighlight && highlight) {
|
if (shouldHighlight && highlight && searchParams !== null && pathname !== null) {
|
||||||
const timer = setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
setHighlight(false);
|
|
||||||
const _searchParams = new URLSearchParams(searchParams);
|
const _searchParams = new URLSearchParams(searchParams);
|
||||||
_searchParams.delete("hl");
|
_searchParams.delete("hl");
|
||||||
router.replace(`${pathname}?${_searchParams.toString()}`);
|
_searchParams.delete("category"); // this comes from params, not from search params
|
||||||
|
|
||||||
|
setHighlight(false);
|
||||||
|
|
||||||
|
const stringifiedSearchParams = _searchParams.toString();
|
||||||
|
|
||||||
|
router.replace(`${pathname}${stringifiedSearchParams !== "" ? `?${stringifiedSearchParams}` : ""}`);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
timeoutRef.current = timer;
|
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
|
@ -75,8 +79,7 @@ export default function AppListCard(props: AppListCardProps) {
|
||||||
timeoutRef.current = null;
|
timeoutRef.current = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [highlight, pathname, router, searchParams, shouldHighlight]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(highlight && "dark:bg-muted bg-yellow-100")}>
|
<div className={classNames(highlight && "dark:bg-muted bg-yellow-100")}>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { test } from "./lib/fixtures";
|
||||||
|
|
||||||
|
test.describe("AppListCard", async () => {
|
||||||
|
test("should remove the highlight from the URL", async ({ page, users }) => {
|
||||||
|
const user = await users.create({});
|
||||||
|
await user.apiLogin();
|
||||||
|
|
||||||
|
await page.goto("/apps/installed/conferencing?hl=daily-video");
|
||||||
|
|
||||||
|
await page.waitForLoadState();
|
||||||
|
|
||||||
|
await page.waitForURL("/apps/installed/conferencing");
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue