Skip to content

#32 autocomplete keyboard - #88

Merged
Janekdererste merged 6 commits into
masterfrom
#32-autocomplete-keyboard
Jun 3, 2021
Merged

Janekdererste merged 6 commits into
masterfrom
#32-autocomplete-keyboard

Conversation

@Janekdererste

Copy link
Copy Markdown
Collaborator

fixes #32
fixes #54
fixes #69

Overhauled the Address Input Component.

  • It should now be possible to use arrow keys to navigate the result list.
  • On Enter the currently selected element from the result list is selected or the first one if no arrow key was pressed before
  • On small screens the fullscreen view can be left with Esc
  • When the Text Input looses focus, the geocoding results are not shown anymore
  • Added a debounce of 500ms. (Maybe that's too much?)

@karussell karussell added this to the 0.3 milestone May 26, 2021

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is very handy 👍

Can we allow entering GPS coordinates directly as mentioned in #54? And should we (not) also trigger an update when we press Enter again?

Btw I just noticed this (triple?) error message:

image

<input
className={styles.input}
type='text'
type="text"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the code formatting settings were off here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in HTML-Tags, the formatting uses ". Everywhere else ' is used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, when I run 'Reformat Code' in IntelliJ it changes the quotes to single quotes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh sorry, I did not know 'Reformat Code' and 'Reformat with Prettier' are two different commands even after enabling the Prettier code style: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360002745119-How-to-have-Reformat-Code-feature-behave-exactly-like-Prettier-

Using Reformat with Prettier the quotes are actually changed to double quotes, unless I add "jsxSingleQuote": true to prettierrc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no! 🙄

Comment thread src/sidebar/search/AddressInput.tsx Outdated
}

private static filterDuplicates = function(hits: GeocodingHit[]) {
private static filterDuplicates = function (hits: GeocodingHit[]) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... same here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is weird.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems to be different for IntelliJ 'Reformat Code' and 'Reformat with Prettier'. The first removes the space and the latter adds it...

What is your workflow for this? Normally I sometimes press 'Alt+Shift+L' to reformat the code in case I want it to be formatted, but then I am just using the 'Reformat Code' checkbox in the Git commit Dialog to make sure whatever I am committing is formatted correctly. I could easily remap the shortcut to the 'Reformat with Prettier' action, but unfortunately there is no equivalent before commit action in the commit dialog. So I would have to setup some kind of external pre-commit logic to achieve the same effect. Or maybe tweak the IntelliJ reformat code rules to match the prettier style (but that seems rather fragile).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have set prettier to reformat the code on safe. So basically every file which I'm about to commit is already properly formatted.

What I'm missing though is automated import optimization. This is something the commit dialog also does for me, but with prettier reformatting on save things get tricky because intellij removes unused imports before the commit, then saves, then prettier kicks in and then I get a warning, that the files I'm about to commit have changed...

The way I have it now, is that I don't do any auto-reformating on commit, but only run code inspection. IntelliJ warns me about unused imports and I remove them manually. It doesn't happen too frequently, but I find it still anoying that I have to take care of imports.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, I'll try this as well then. We probably need to re-format the entire code base again then, because when I did this I used 'Reformat code' instead of 'Reformat with Prettier' because I did not know they weren't the same... Maybe this is also why @karussell saw different formatting when using prettier in vscode...

@easbar

easbar commented May 26, 2021

Copy link
Copy Markdown
Member

Probably also a bit off-topic, but the profile selection seems to contain some invalid options:

image

@karussell

Copy link
Copy Markdown
Member

Probably also a bit off-topic, but the profile selection seems to contain some invalid options:

This is also a problem on old GraphHopper Maps and will be fixed once the latest shared-outdoor is deployed (that removes some custom profiles that I wanted to test out)

@Janekdererste

Copy link
Copy Markdown
Collaborator Author

Btw I just noticed this (triple?) error message:

This is because we have three errors coming from the backend. The Error handler just connects each error with an "and". This could be improved in general. Together with unhelpful messages if no route was found. Related to #70

@Janekdererste

Copy link
Copy Markdown
Collaborator Author

And should we (not) also trigger an update when we press ...

I don't think so. Why trigger anything if nothing has changed?

@easbar

easbar commented Jun 3, 2021

Copy link
Copy Markdown
Member

This is because we have three errors coming from the backend. The Error handler just connects each error with an "and". This could be improved in general. Together with unhelpful messages if no route was found. Related to #70

Ah ok, so let's fix this in #70 then.

I don't think so. Why trigger anything if nothing has changed?

Hm, my use-case is often debugging (I need to trigger the request to check something on the server-side). So rather special I know :) But then again, as a user I also somehow feel like I want to 'control' the app, so in case I push Enter I expect something to 'happen'... For example when I move the map, pushing Enter should also scroll the map back to the path (?)

@Janekdererste

Copy link
Copy Markdown
Collaborator Author

Hm, my use-case is often debugging (I need to trigger the request to check something on the server-side). So rather special I know :) But then again, as a user I also somehow feel like I want to 'control' the app, so in case I push Enter I expect something to 'happen'... For example when I move the map, pushing Enter should also scroll the map back to the path (?)

Okay this makes sense then. Doing it from within the address search component is not so trivial though. Which behaviour do we want in this case? Simply try to use the text-input's content as coordinate? Only if it has changed since the last time? Or should the Enter -> Search thing be a more global thing? Also, should the search be triggered only in case an input box is highlighted or again at any time?

While writing this it sounds like this is a global functionality. If it is okay for you, I would put this off until later and put it into another issue. Otherwise we have to discuss first I guess.

@easbar

easbar commented Jun 3, 2021

Copy link
Copy Markdown
Member

Sure! This PR already improves so many things, no need to do everything at once.

@Janekdererste
Janekdererste merged commit 99f700e into master Jun 3, 2021
@Janekdererste
Janekdererste deleted the #32-autocomplete-keyboard branch June 3, 2021 10:29
ZeroGxMax pushed a commit to minhhpkp/graphhopper-maps that referenced this pull request Nov 12, 2024
* Navigate geocoding results with arrow keys

* Leave full screen on Esc

* Fix broken border around geocoding autocomplete

* Add debounce to geocoding

* remove logging

* Clean up AddressInput.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

introduce a small 100ms delay for geocoding leaving input with tab should work (keyboard navigation) Use up/down cursor for autocomplete selection

3 participants