Skip to content

Commit

Permalink
Merge pull request #190 from scarletstudio/input_focus_fix
Browse files Browse the repository at this point in the history
Fix for Modal Closing when Input is Focused
  • Loading branch information
fabrego524 authored Aug 10, 2021
2 parents aed940a + 56cd6da commit 81dc6cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/components/SearchableMetricSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function filterSearchResults(supportedMetrics, searchText){
function Modal(props){
const { supportedMetrics, onClose, selectMetric, show } = props;
const [searchText, setSearchText] = useState("")
const [focus, setFocus] = useState(0)

if(!show){
return null;
}
Expand All @@ -78,7 +80,7 @@ function Modal(props){


return (
<div className="selectorModal" onClick={onClose} >
<div className="selectorModal" onClick={focus ? undefined : onClose} >
<div className="modalContent" onClick={e => e.stopPropagation() } >
<div className="modalHeader" >
<h4 className="modalTitle">Select your Metric</h4>
Expand All @@ -90,6 +92,8 @@ function Modal(props){
value={searchText}
placeholder="Search Metrics..."
onChange={(e) => setSearchText(e.target.value)}
onFocus={() => setFocus(1)}
onBlur={() => setFocus(0)}
/> </p>

<p>{searchResultsMessage}</p>
Expand Down

0 comments on commit 81dc6cb

Please sign in to comment.