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

Extract phx-feedback-for #3086

Closed
wants to merge 6 commits into from

Conversation

SteffenDE
Copy link
Collaborator

@SteffenDE SteffenDE commented Feb 4, 2024

This PR extends #3084 and moves the phx-feedback-for functionality into its own file.

Relates to #3084.
Fixes #3071.

`phx-no-feedback` is a class that is added to elements with the
`phx-feedback-for` attribute when the corresponding elements were not
interacted with yet. The problem with the current approach is that LV
of course removes the added class when the DOM is patched. Therefore we
were relying on tracking all input elements on each patch to properly
hide the feedback. This worked fine until the magicId optimization. Now,
whole sections of the DOM could be skipped on a patch, not tracking
inputs inside them and therefore not hiding feedback on the
corresponding containers.

This all was built before we had the `JS` module, which gives us a nice
way to permanently apply classes to an element, even if it is patched.
Using this functionality, we can now apply the `phx-no-feedback` class
correctly when we first render the page. This way, we don't need remove
the class on each patch, and we don't rely on tracking all inputs in
dom_patch. When we then interact with the input, or submit the form,
we show the feedback again as usual, removing the sticky class from the
feedback containers.

Fixes phoenixframework#3071.
We want to remove phx-feedback-for in LiveView 1.0 for a better solution.
This commit extracts the phx-feedback-for into its own file that can be
dropped in by users for backwards compatibility.

Relates to phoenixframework#3084
@SteffenDE SteffenDE force-pushed the extract_feedback branch 2 times, most recently from 0ea80b8 to 9909010 Compare February 5, 2024 17:38
@chrismccord
Copy link
Member

Will revisit when input_changed?/1 is rolled out

@chrismccord chrismccord closed this Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants