Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete text after selecting same item from list. #358

Open
karussell opened this issue Sep 13, 2023 · 5 comments
Open

Incomplete text after selecting same item from list. #358

karussell opened this issue Sep 13, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@karussell
Copy link
Member

When I initially have this URL and type 'hoyersw' in the first input field and click on the first result of the autocomplete, which would be the same text as in the URL (Hoyerswerda - Wojerecy), then the input stays at 'hoyers' instead of 'Hoyerswerda - Wojerecy'

@kriegalex
Copy link
Contributor

I have been able to reproduce.

The pattern is always the same :

  1. Select a new input search
  2. The autocomplete works
  3. Empty the cell
  4. Type something that gives the same autocomplete result (props.point.queryText)
  5. Select the same result
  6. Input fields doesn't switch to autocomplete suggestion
  7. Using console.log, we see that useEffect => setText is not triggered to update the text from "input" to "queryText"

@kriegalex
Copy link
Contributor

if (action instanceof InvalidatePoint) {
  const points = QueryStore.replacePoint(state.queryPoints, {
    ...action.point,
    isInitialized: false,
    queryText: ''
  });
  return {
    ...state,
    queryPoints: points,
  };
} else if (action instanceof ClearPoints) {

Query text must be emptied for the change to be registered by useEffect().

useEffect(() => {
  setText(props.point.queryText);
  console.log('useEffect: '+props.point.queryText);
}, [props.point.queryText]);

Is that correct ? I'm still learning Typescript and web development.

@karussell
Copy link
Member Author

karussell commented Oct 30, 2023

Oh, nice. Indeed the first code you mentioned already fixes the problem and is what we need here, I guess! Feel free to create a pull request or I can mention you in the commit to credit you properly :)

karussell added a commit that referenced this issue Dec 3, 2023
…complete text after selecting same item from list, fixes #358"

This reverts commit f45f4c5.
@karussell
Copy link
Member Author

karussell commented Dec 3, 2023

Unfortunately I had to revert it as it breaks editing the input text: 1. search for something and click the suggestion. 2. click again on the input element and whatever you type the input will be (incorrectly) cleared before it.

@karussell karussell reopened this Dec 3, 2023
@kriegalex
Copy link
Contributor

Understood. Makes total sense. Next time, I'll mark it as untested explicitely (more like an hint to follow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants