diff --git a/src/components/Dropdown/Checkbox.tsx b/src/components/Dropdown/Checkbox.tsx index a3e92324b2..bca18875e8 100644 --- a/src/components/Dropdown/Checkbox.tsx +++ b/src/components/Dropdown/Checkbox.tsx @@ -28,8 +28,8 @@ const StyledCheckbox = styled.span<{ isChecked: boolean }>` content: ${({ isChecked }) => (isChecked ? "'✓'" : "''")}; color: black; position: absolute; - top: 0; - left: 3px; + top: -2px; + left: 2px; font-size: 14px; } ` diff --git a/src/components/Dropdown/Dropdown.tsx b/src/components/Dropdown/Dropdown.tsx index 71a007099a..79aa56770a 100644 --- a/src/components/Dropdown/Dropdown.tsx +++ b/src/components/Dropdown/Dropdown.tsx @@ -1,5 +1,5 @@ import styled from '@emotion/styled' -import React, { useState } from 'react' +import React, { useEffect, useRef, useState } from 'react' import Checkbox from './Checkbox' // Import the CustomCheckbox interface DropdownProps { @@ -15,6 +15,7 @@ const Dropdown: React.FC = ({ }) => { const [selectedOptions, setSelectedOptions] = useState([]) const [isExpanded, setIsExpanded] = useState(false) + const dropdownRef = useRef(null) const handleSelect = (option: string) => { let newSelectedOptions = [] @@ -41,8 +42,28 @@ const Dropdown: React.FC = ({ setIsExpanded(!isExpanded) } + const handleClickOutside = (event: MouseEvent) => { + if ( + dropdownRef.current && + !dropdownRef.current.contains(event.target as Node) + ) { + setIsExpanded(false) + } + } + + useEffect(() => { + if (isExpanded) { + document.addEventListener('mousedown', handleClickOutside) + } else { + document.removeEventListener('mousedown', handleClickOutside) + } + return () => { + document.removeEventListener('mousedown', handleClickOutside) + } + }, [isExpanded]) + return ( - + {title} diff --git a/src/containers/Operator/OperatorContainer.tsx b/src/containers/Operator/OperatorContainer.tsx index 0ec47a8c5e..dc012f99e1 100644 --- a/src/containers/Operator/OperatorContainer.tsx +++ b/src/containers/Operator/OperatorContainer.tsx @@ -1,5 +1,5 @@ import { OperatorDetails } from '@/components/Operator/OperatorDetails' -import { SimilarOperators } from '@/components/Operator/SimilarOperators' +// import { SimilarOperators } from '@/components/Operator/SimilarOperators' import styled from '@emotion/styled' import { useRouter } from 'next/router' import React from 'react' @@ -25,7 +25,7 @@ const ExploreOperator: React.FC = ({ id }) => { Share icon - + {/* */} ) }