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

LiveSelect wipes out the underlying value when focus is received #86

Closed
sachamasry opened this issue Oct 28, 2024 · 2 comments
Closed

Comments

@sachamasry
Copy link

LiveSelect and LiveView versions

LiveView version: 1.0.0-rc.1
LiveSelect version: 1.4.2

Describe the bug
In a LiveView app, I'm trying to use live_select as a more user-friendly substitute to HTML select controls, with all options preloaded.

So, I have replaced select with live_select on a form_component.ex live component, sitting on top of a foreign key field. When creating a new entity, live_select works as expected, letting the user type ahead and select one of the options. While still in the :new live_action of the form (not having saved the entity yet), clicking back into the live_select field clears the option. Clicking out of the field brings the option back, as per design decisions.

Once the entity is saved, and the user chooses to edit it subsequently—the :edit live_action of the form—the correct option is displayed in the live_select control, with the correct id value in the hidden input field, with the help of the component's value_mapper option.

However, when the field receives focus now—whether through a mouse click or through keyboard tabbing into the field—the value is again lost, but not subsequently reinstated on the blur event. Inspection of the hidden input field also shows it to be empty now. This happens even when the value_mapper option is unused, and the field is left to display the raw id of the referenced entity.

This appears to be buggy behaviour.

Expected behaviour
I would imagine that the value would be replaced back into the field, as is the case when creating a new entity.

Actual behaviour
When the field receives focus, it clears the value of both input fields, and leaves their value empty, even after the blur event takes place.

Screenshots
live_select_bug_demonstration

Browsers
Firefox stable and nightly, Safari, Arc

Issue Repo
A minimal demonstration repo reproducing the problem

@maxmarcon
Copy link
Owner

duplicate of #81, already fixed by #82. New version released

@sachamasry
Copy link
Author

Thanks @maxmarcon! The latest version works perfectly.

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

No branches or pull requests

2 participants