Skip to content

Conversation

Yashaswini-Sharma
Copy link
Contributor

Fix: Preserve Original Case in phx-disable-with Elements

Summary

This change addresses Fixes #4015 by updating the phx-disable-with logic to use el.textContent instead of el.innerText when storing and restoring the original content of a disabled element.

This ensures that the original, case-sensitive text is correctly restored once the element is re-enabled—preventing issues caused by CSS transformations (like text-transform: uppercase) that were permanently altering displayed text.


Background

The phx-disable-with attribute in Phoenix temporarily replaces an element’s content while a form is being submitted and restores it once the request completes.

Previously, this logic used el.innerText to capture the element’s text. However:

  • innerText returns rendered text (affected by CSS styles like text-transform).
  • As a result, elements with styles such as text-transform: uppercase would store the modified version of the text (“INCREASE”) instead of the original one (“Increase”).

This behavior caused problems in automated testing tools (e.g., Cypress) that rely on exact, case-sensitive text matching.


Fix

This update replaces:

el.innerText

@SteffenDE
Copy link
Collaborator

Thank you, please undo the changes to the priv folder. The assets are updated after merging.

@SteffenDE
Copy link
Collaborator

Thank you @Yashaswini-Sharma,

I fixed it via #4017 and added you as co-author.

If you want to look less like AI, don't put so much effort into formatting your markdown. No human would do that :)

@Yashaswini-Sharma
Copy link
Contributor Author

Hi I am so sorry T_T, this is my first time contributing to a big repo. Thank you so much for your help! Usually I have heard there is a template for PRs but I am sorry I could not find it so I had gemini generate one for me

@SteffenDE
Copy link
Collaborator

All good, no worries!

We only have an issue template. For PRs, if you just fix an existing issue, linking to it is usually all you need. I'd say you only need to provide as much information as necessary, so if the issue has a good description of what's wrong, that's already good. All you need to describe in the PR is things that are worth additional explanation, because they're not immediately clear from the code and the issue itself.

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.

phx-disable-with can cause the text content to change

3 participants