mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-22 08:08:13 +00:00
fix: event problem after select suggestion
This commit is contained in:
parent
49e9e3f69a
commit
0468ec4ad3
@ -12,16 +12,10 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.autocomplete-input:focus {
|
|
||||||
outline: none;
|
|
||||||
border: 2px solid #4360DF;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suggestion-list {
|
.suggestion-list {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
max-height: 210px;
|
max-height: 260px;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
border: 1px solid #f7f8f9;
|
border: 1px solid #f7f8f9;
|
||||||
border-radius: 24px;
|
border-radius: 24px;
|
||||||
|
@ -36,7 +36,8 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSuggestionClick = (suggestion: string) => {
|
const handleSuggestionClick = (e: React.MouseEvent, suggestion: string) => {
|
||||||
|
e.preventDefault()
|
||||||
setIsFocused(false)
|
setIsFocused(false)
|
||||||
dispatch(setWord({ index, word: suggestion }))
|
dispatch(setWord({ index, word: suggestion }))
|
||||||
}
|
}
|
||||||
@ -49,6 +50,16 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
|||||||
setIsFocused(false)
|
setIsFocused(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const styleForInput = () => {
|
||||||
|
const style = { outline: 'none' }
|
||||||
|
|
||||||
|
if (isFocused) {
|
||||||
|
return { ...style, border: '2px solid #4360DF', marginBottom: '5px' }
|
||||||
|
} else {
|
||||||
|
return style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="autocomplete-container">
|
<div className="autocomplete-container">
|
||||||
<div className={isFocused ? 'suggestion-list' : ''}>
|
<div className={isFocused ? 'suggestion-list' : ''}>
|
||||||
@ -58,13 +69,14 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
|||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
onFocus={handleInputFocus}
|
onFocus={handleInputFocus}
|
||||||
onBlur={handleInputBlur}
|
onBlur={handleInputBlur}
|
||||||
|
style={styleForInput()}
|
||||||
/>
|
/>
|
||||||
{isFocused &&
|
{isFocused &&
|
||||||
suggestions.map(suggestion => (
|
suggestions.map(suggestion => (
|
||||||
<div
|
<div
|
||||||
key={suggestion}
|
key={suggestion}
|
||||||
className="suggestion-item"
|
className="suggestion-item"
|
||||||
onMouseDown={() => handleSuggestionClick(suggestion)}
|
onMouseDown={e => handleSuggestionClick(e, suggestion)}
|
||||||
>
|
>
|
||||||
{suggestion}
|
{suggestion}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user