Skip to content

Conversation

bratsche
Copy link
Contributor

@bratsche bratsche commented Feb 4, 2025

When in tags mode if you type something into the text field, focus your cursor out of the component and then back into it, then it gets into a weird state. The text that you've typed into the input disappears when your blur, but when you focus again the selections remain as they were before the blur (so that the user needs to type something and then backspace it away in order to reset the selections).

This PR takes the approach of maintaining the current text in the input field when blurring the cursor away from it.

Here's a clip demonstrating the bug:

select-bug.mov

Here's a clip demonstrating with this PR:

select-fix.mov

@bratsche
Copy link
Contributor Author

@maxmarcon ping, just wanted to see if you had some thoughts on this or if there's anything else I can do to help get this fixed?

@maxmarcon
Copy link
Owner

Hi sorry for the delay. Good catch. One question: doesn't the same thing happen in single mode? Shouldn't we fix both? Thanks

@bratsche
Copy link
Contributor Author

@maxmarcon Sorry for the delay on my end this time. :) I tested in single mode and, you're right, I see the same issue there. I added another commit to this PR which appears to solve it for me.

@maxmarcon
Copy link
Owner

maxmarcon commented Mar 30, 2025

your changes break single mode. If I select something, the input box doesn't show the selection, but the text that I have entered. This was the purpose of this logic:

 if (mode === "single") {
                        const label = selection.length > 0 ? selection[0].label : null
                        this.setInputValue(label)
}

which you removed.

Screen.Recording.2025-03-30.at.19.12.58.mov

@maxmarcon
Copy link
Owner

maxmarcon commented Mar 30, 2025

Maybe using:

const label = selection.length > 0 ? selection[0].label : current_text

could be enough to fix it.

@bratsche
Copy link
Contributor Author

@maxmarcon Thank you, I pushed that change now.

@maxmarcon maxmarcon merged commit e969085 into maxmarcon:main Mar 31, 2025
5 checks passed
@maxmarcon
Copy link
Owner

merged - plus enabled the same logic for quick_tags mode as well, cause it makes sense. Thanks!

@bratsche bratsche deleted the tags-mode-current-text-on-blur-focus branch March 31, 2025 13:46
@maxmarcon
Copy link
Owner

maxmarcon commented Jun 16, 2025

Hi @bratsche I reverted these changes and made the behavior you're expecting here opt-in. Now

  • by default, both the current text in the input field and the list of selectable options are cleared upon selection
  • if the user sets keep_options_on_select: true in the component's assigns, both the value of the text input field as well as the list of options are persisted upon selection.

May I kindly ask you to test your code against the latest main, using the keep_options_on_select assign, and check if it matches your expectations? Thank you so much!

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.

2 participants