Skip to content

Commit

Permalink
use escaper hook for advanced search options
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikeW committed Aug 2, 2022
1 parent 9015775 commit f8ed443
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions frontend/src/components/QuickAdd.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import React, { useState, useRef } from "react";
import { IdName, Issue, IssueActivityPair } from "../model";
import { getApiEndpoint, useDebounce } from "../utils";
import plus from "../icons/plus.svg";
import x from "../icons/x.svg";
import check from "../icons/check.svg";
import { AuthContext } from "../components/AuthProvider";
import { PUBLIC_API_URL, headers } from "../utils";
import { PUBLIC_API_URL, headers, useEscaper } from "../utils";
import * as ReactDOM from "react-dom";

export const QuickAdd = ({
Expand Down Expand Up @@ -183,6 +183,13 @@ export const QuickAdd = ({
}
};

const handleHideAutocomplete = () => {
setIsAutoCompleteVisible(false);
};

const wrapperRef = useRef(null);
useEscaper(wrapperRef, handleHideAutocomplete);

return (
<div>
<h2> Add a new row</h2>
Expand Down Expand Up @@ -237,7 +244,7 @@ export const QuickAdd = ({
</button>
</div>
{search.suggestions.length > 0 && isAutoCompleteVisible && (
<ul className="col-8 autocomplete-container">
<ul className="col-8 autocomplete-container" ref={wrapperRef}>
{search.suggestions.map((item) => (
<li key={item.id} className="autocomplete-item">
<button
Expand Down

0 comments on commit f8ed443

Please sign in to comment.