live_select icon indicating copy to clipboard operation
live_select copied to clipboard

No way to render selected options errors as part of the component

Open a3kov opened this issue 10 months ago • 1 comments

Currently there's no way to render a selected option error. For example, if somebody is using LS with embeds/assocs, they may have an error in currently selected option. Let's say a user picks an option and saves it in the DB. Initially the option is valid, but later becomes invalid due to external events, and we need to highlight this next time the form is rendered. Then the user's job is to review the invalid options and to remove them. We obviously can't do that automatically, as that would be terrible UX.

If there are errors on the association level, they can be rendered with the text field, but that is not good enough, as some options can be valid so we need to distinguish between them. Besides, the text field is only for entering new options, and is not associated UI-wise with the selection.

a3kov avatar Feb 21 '25 10:02 a3kov

One of the issues here is that the whole component is general purpose and assocs/embeds is just one of the ways you could store the options. Otherwise using inputs_for to render selection would make perfect sense.

Unfortunately the whole module is not flexible enough - it really should not try to support every case via classes (it fails exactly in cases like this one). Instead it should let the user override whole chunks of the template via own function components. If you want full control of the markup the right way here is vendoring the package which is sad state of affairs.

I managed to hack a solution, but I'm not happy about because it involves manual work with the backing changeset.

a3kov avatar Feb 21 '25 20:02 a3kov