Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Dec 6, 2024
1 parent 5191c54 commit fb910bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/sidebar/search/AddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default function AddressInput(props: AddressInputProps) {
<PlainButton
className={styles.btnClose}
onMouseDown={(e) =>
e.preventDefault() // prevents that input->onBlur is called when just "mouse down" event (lose focus only for a proper click)
e.preventDefault() // prevents that input->onBlur is called when just "mouse down" event (lose focus only for onClick)
}
onClick={() => searchInput.current!.blur()}
>
Expand Down Expand Up @@ -231,7 +231,7 @@ export default function AddressInput(props: AddressInputProps) {
onClick={(e) => {
setText('')
props.onChange('')
// if we clear the text without focus then explicitely request it:
// if we clear the text without focus then explicitly request it to improve usability:
searchInput.current!.focus()
}}
>
Expand Down Expand Up @@ -269,7 +269,7 @@ export default function AddressInput(props: AddressInputProps) {
handlePoiSearch(poiSearch, item.result, props.map)
setText(item.result.text(item.result.poi))
}
searchInput.current!.blur() // is called in combination with e.preventDefault in AutocompleteEntry->onMouseDown
searchInput.current!.blur() // see also AutocompleteEntry->onMouseDown
}}
/>
</ResponsiveAutocomplete>
Expand Down
7 changes: 4 additions & 3 deletions src/sidebar/search/AddressInputAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,17 @@ function AutocompleteEntry({
return (
<button
className={className}
onMouseDown={e => {
e.preventDefault() // prevent blur event for our input, see #398
}}
// using click events for mouse interaction and touch end to select an entry.
onClick={() => onSelect()}
// minor workaround to improve success rate for click even if start and end location on screen are slightly different
onTouchEnd={e => {
e.preventDefault() // do not forward click to underlying component
onSelect()
}}
onMouseDown={e => {
e.preventDefault() // Prevent blur event for our input, see #398.
// See also the onMouseDown calls in the buttons in AddressInput.tsx created for the same reason.
}}
>
{children}
</button>
Expand Down

0 comments on commit fb910bb

Please sign in to comment.