Skip to content

Commit

Permalink
Proper syncing of search result input
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Jun 23, 2022
1 parent c65a22c commit 0a47519
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/GeoTaggingWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ const GeoTaggingWidget = props => {
setAdvancedEditing(false);

const onSearch = ({ search, result }) => {
setSearch(search);

if (result) {
const updated = {
...toBody(result),
Expand Down Expand Up @@ -111,6 +109,7 @@ const GeoTaggingWidget = props => {
onShowMinimap={() => setShowMinimap(true)}
onDeleteGeoTag={onDelete}
onSearch={onSearch}
onChangeSearch={setSearch}
onCollapseToCentroid={onCollapseToCentroid}
onGoAdvanced={() => setAdvancedEditing(true)} />

Expand All @@ -127,6 +126,7 @@ const GeoTaggingWidget = props => {
config={props.config}
search={search}
feature={body}
onChangeSearch={setSearch}
onOk={onAdvacedEditingDone}
onCancel={onAdvacedEditingCanceled} />
}
Expand Down
3 changes: 2 additions & 1 deletion src/advanced/AdvancedModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const AdvancedModal = props => {
});
}

const onSearch = result => {
const onSearch = ({ result }) => {
clearMap();

const { uri, geometry } = result;
Expand Down Expand Up @@ -122,6 +122,7 @@ const AdvancedModal = props => {
<SearchInput
config={props.config}
value={props.search}
onChange={props.onChangeSearch}
onSearch={onSearch} />

<div className="r6o-geotagging-advanced-modal-header-buttons">
Expand Down
8 changes: 7 additions & 1 deletion src/search/SearchInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const SearchInput = props => {
// If there's an initial search, run query
if (search && props.initialSearch) query();
}, []);

const onChange = evt => {
const { value } = evt.target;
setSearch(value);
props.onChange(value);
}

const onKeyDown = evt => {
if (evt.key === 'Enter')
Expand All @@ -52,7 +58,7 @@ const SearchInput = props => {
<input
placeholder="Search for a place..."
value={search}
onChange={evt => setSearch(evt.target.value)}
onChange={onChange}
onKeyDown={onKeyDown}/>

{loading &&
Expand Down
1 change: 1 addition & 0 deletions src/toolbar/WhenExpanded.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const WhenExpanded = props => {
initialSearch
config={props.config}
value={props.search}
onChange={props.onChangeSearch}
onSearch={props.onSearch} />

<button
Expand Down

0 comments on commit 0a47519

Please sign in to comment.