Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): click on mention list on search bar in modal bug #2098

Merged
merged 5 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ export const MentionList = forwardRef<MentionListRef, MentionListProps>(
const { suggestionsRef, shouldShowScrollToBottomIcon, scrollToBottom } =
useSuggestionsOverflowHandler();

const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
event.preventDefault();
event.stopPropagation();
};

return (
<div className="items flex flex-1 flex-col p-2 px-4 bg-gray-50 rounded-md shadow-md z-40 max-h-[200px]">
<div
className="items flex flex-1 flex-col p-2 px-4 bg-gray-50 rounded-md shadow-md z-40 max-h-[200px]"
onClick={handleClick}
>
<div
className="flex flex-1 flex-col overflow-y-auto"
ref={suggestionsRef}
Expand Down
3 changes: 1 addition & 2 deletions frontend/lib/components/SearchModal/SearchModal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

.search_modal_wrapper {
display: flex;
background-color: Colors.$dark-black;
background-color: rgba(Colors.$dark-black, 0.94);
height: 100%;
width: 100%;
position: absolute;
z-index: ZIndexes.$modal;
opacity: 0.94;
align-items: center;
justify-content: center;

Expand Down
14 changes: 5 additions & 9 deletions frontend/lib/components/SearchModal/SearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export const SearchModal = (): JSX.Element => {
const { isVisible, setIsVisible } = useSearchModalContext();
const searchBarRef = useRef(null);

useEffect(() => {
console.log(`isVisible has changed to: ${isVisible}`);
}, [isVisible]);

const keydownHandler = ({
key,
metaKey,
Expand All @@ -28,7 +24,7 @@ export const SearchModal = (): JSX.Element => {
}
};

const mousedownHandler = (event: MouseEvent) => {
const clickHandler = (event: MouseEvent) => {
if (
!(searchBarRef.current as HTMLElement | null)?.contains(
event.target as Node
Expand All @@ -43,12 +39,12 @@ export const SearchModal = (): JSX.Element => {
};

useEffect(() => {
document.addEventListener("keydown", keydownHandler);
window.addEventListener("click", mousedownHandler);
window.addEventListener("keydown", keydownHandler);
window.addEventListener("click", clickHandler);

return () => {
document.removeEventListener("keydown", keydownHandler);
window.removeEventListener("click", mousedownHandler);
window.removeEventListener("keydown", keydownHandler);
window.removeEventListener("click", clickHandler);
};
}, []);

Expand Down
Loading