Skip to content

Commit

Permalink
save annotation when pressing Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
satellitestudiodesign committed Dec 14, 2023
1 parent 5dd48e1 commit bdd6f5f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions apps/fishing-map/features/map/annotations/Annotations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useSelector } from 'react-redux'
import cx from 'classnames'
import { Popup } from 'react-map-gl'
import { useTranslation } from 'react-i18next'
import { KeyboardEventHandler } from 'react'
import {
Button,
ColorBar,
Expand Down Expand Up @@ -43,6 +44,11 @@ const MapAnnotations = () => {
})
resetMapAnnotation()
}
const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (e) => {
if (e.key === 'Enter') {
onConfirmClick()
}
}

return (
<Popup
Expand All @@ -60,6 +66,7 @@ const MapAnnotations = () => {
value={mapAnnotation.label}
onChange={(e) => setMapAnnotation({ label: e.target.value })}
placeholder={t('map.annotationPlaceholder', 'Type something here')}
onKeyDown={handleKeyDown}
/>
<ColorBar
colorBarOptions={colors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const MapAnnotationsControls = () => {
expanded={mapAnnotations?.length > 0}
tooltip={
isAnnotating
? t('map.annotationsStop', 'Stop annotations')
? t('map.annotationsStop', 'Stop editing annotations')
: t('map.annotationsAdd', 'Add annotation')
}
onClick={onToggleClick}
Expand Down
2 changes: 1 addition & 1 deletion apps/fishing-map/features/map/controls/RulersControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Rulers = () => {
expanded={rulers?.length > 0}
tooltip={
rulersEditing
? t('map.rulersStop', 'Stop measures')
? t('map.rulersStop', 'Stop editing measures')
: t('map.rulers_add', 'Measure distance')
}
onClick={onToggleClick}
Expand Down

0 comments on commit bdd6f5f

Please sign in to comment.