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

Fix label display initialization in Forms #17519

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Habbni
Copy link
Contributor

@Habbni Habbni commented Feb 24, 2025

There is an easily reproducable bug in the forms input label display initialization: When you set an input[text] element´s label in a form that also contains a an input[submit], all label options will be hidden on load. This is really annoying, because users have to switch the input´s type to something else and back to text, so the eventListeners make the labels reappear.

Steps to reproduce:

  • edit a contentItem with a form part
  • add an input element of type "text", set it´s label option to "standard" and enter an arbitrary label text
  • add another input element of type "submit" (this is crucial)
  • save the content item, reopen it
  • the "label option" and "label text" elements are now hidden. you have to switch input type to something else and back to "text" to re-display them

The expected behaviour was that labeled input elements would display "label option" and "label text" on load.

There is an initialization problem when selectOptionsEditor.initilizeFieldType is called with the whole document passed in as wrapper. within that method, change event listeners are being attached to the type select elements. those listeners then use the whole document as parent for setting "d-none" classes. Therefore, the hide-logic gets applied to every label in the form.

Same issue exists within formElementLabelManager.
A simple fix is to only use the closest widget-editor-body as parent.

This pull request provides the described fix to this issue

…s logic only to closest parent, instead of wrapper parameter, to avoid whole document being affected
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.

1 participant