Skip to content

Commit

Permalink
Merge pull request #11 from newfold-labs/fix_capability_check
Browse files Browse the repository at this point in the history
don't render search component when modal is not visible
  • Loading branch information
earnjam authored Jun 30, 2023
2 parents b4cf95d + 711d338 commit f1207c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/HelpCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "@wordpress/element";
import algoliasearch from "algoliasearch";
import { Configure, Index, InstantSearch } from "react-instantsearch-hooks-web";
import SearchResults from "./SearchResults";
import { CapabilityAPI } from "../utils";
import { CapabilityAPI, LocalStorageUtils } from "../utils";

const HelpCenter = (props) => {
// Set up the instant search results
Expand All @@ -11,6 +11,7 @@ const HelpCenter = (props) => {
"eef54890add97ea2583ff1e417ff86ea"
);

const visible = LocalStorageUtils.getHelpVisible();
const [helpEnabled, setHelpEnabled] = useState(false);
const getHelpStatus = async () => {
try {
Expand All @@ -24,7 +25,7 @@ const HelpCenter = (props) => {
getHelpStatus();
}, []);

if (!helpEnabled) {
if (!helpEnabled || !visible) {
return <></>;
}

Expand Down

0 comments on commit f1207c9

Please sign in to comment.