import { __ } from "@wordpress/i18n"; import React, { useEffect } from "react"; import UncategorizedFaq from "./UncategorizedFaq"; import { scrollExpandedIntoView } from "../utils/function"; // icons import { ReactComponent as DownArrow } from "./../assets/images/down-arrow.svg"; import FaqLoader from "../utils/FaqLoader"; const UncategorizedFaqList = ({ categoriesLoading, allFaqCategories, reFetchCategories, allUncategorizedFaq, setFetchUncategorizedFaq, categoryExpanded, setCategoryExpanded, setCreateFaqAt, faqExpanded, setFaqExpanded, setReFetchFaqForCategory, uncategorizedFaqLoading, uncategorizedFaqFetching, highlightGroupId, }) => { // Focus target after a FAQ is created without a group: open + scroll the // panel so the new FAQ row (which flashes itself) is visible. const isHighlighted = highlightGroupId === "uncategorized"; useEffect(() => { if (!isHighlighted) return; setCategoryExpanded("uncategorized"); setFetchUncategorizedFaq && setFetchUncategorizedFaq(); scrollExpandedIntoView("ctg-uncategorized"); }, [isHighlighted]); const handleShow = () => { if (categoryExpanded == "uncategorized") { setCategoryExpanded(undefined); } else { setCategoryExpanded("uncategorized"); // Fetch on open (like the categorized groups) so the loader shows. setFetchUncategorizedFaq && setFetchUncategorizedFaq(); } }; return (