mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
fix(dashboard/api-manager): scroll to key name error in create modal
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useMemo, useCallback, memo } from "react";
|
||||
import { useState, useEffect, useMemo, useCallback, memo, useRef } from "react";
|
||||
import { Card, Button, Input, Modal, CardSkeleton } from "@/shared/components";
|
||||
import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
|
||||
import { useTranslations } from "next-intl";
|
||||
@@ -154,6 +154,7 @@ export default function ApiManagerPageClient() {
|
||||
const [usageStats, setUsageStats] = useState<Record<string, KeyUsageStats>>({});
|
||||
const [sessionCounts, setSessionCounts] = useState<Record<string, number>>({});
|
||||
const [allowKeyReveal, setAllowKeyReveal] = useState(false);
|
||||
const createKeyNameFieldRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [activeOnly, setActiveOnly] = useState(false);
|
||||
@@ -169,6 +170,13 @@ export default function ApiManagerPageClient() {
|
||||
fetchConnections();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!showAddModal || !nameError) return;
|
||||
requestAnimationFrame(() => {
|
||||
createKeyNameFieldRef.current?.scrollIntoView({ block: "center", behavior: "instant" });
|
||||
});
|
||||
}, [nameError, showAddModal]);
|
||||
|
||||
useEffect(() => {
|
||||
setActiveOnly(readActiveOnlyPreference());
|
||||
}, []);
|
||||
@@ -1034,7 +1042,7 @@ export default function ApiManagerPageClient() {
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div>
|
||||
<div ref={createKeyNameFieldRef}>
|
||||
<label className="text-sm font-medium text-text-main mb-1.5 block">
|
||||
{t("keyName")}
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user