- Issue created by @aaron.ferris
- π³πΏNew Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies β . Also, Drupal 10.4 is in maintenance mode.
- π΅πΉPortugal dxvargas
I have a simpler use case where paragraphs is not needed, just Field group. It can be replicated in latest D11.
I'm attaching an image with the configuration bellow.- Go to the "Basic Page" content type
- Make body required
- Add an image field
- Go to the form display page
- Add vertical tabs "Tabs" with tab "Tab 1" and tab "Tab 2"
- Put "Tab 1" and "Tab 2" inside "Tabs"
- Put "Title" and "image" inside "Tab 1"
- Put "Body" inside "Tab 2"
- Go to the Basic page creation form
- Fill the title and submit
- The form is submitted and there will be an error because Body is empty. The visible tab will be "Tab 2" by now, this is correct.
- Go to back to "Tab 1"
- Upload an image
- The tab "Tab 1" is hidden and we jump to "Tab 2" with the body. This should not happen.
The problem exists whenever:
- A validation error exists in field A
- A field B that updates the DOM of the page is changed
- The field A and B are in different tabs.
The problem comes from the core file
web/core/misc/vertical-tabs.js
.
When an image is uploaded (or removed), there is a change in the DOM. Then, every time there is a "DOMContentLoaded" event, thecontext.querySelectorAll()
inDrupal.behaviors.verticalTabs
is triggered and it looks for tabs with errors and programmatically clicks them. This is what makes our tab that has the body to be visible. - Merge request !12433Issue #3508418: Fix odd behaviour with vertical tabs on validation failure β (Open) created by dxvargas
- π΅πΉPortugal dxvargas
The code to focus the tab with errors should happen inside a "once", to not run after AJAX events.
This is basically the main change I am proposing.The focus of the tab with errors is covered already in
\Drupal\FunctionalJavascriptTests\Core\Form\FormGroupingElementsTest::testVerticalTabValidationVisibility()
and it is passing in my MR. - πΊπΈUnited States smustgrave
Seems like something probably should have test coverage for.
Also tagging for IS update as the proposed solution isn't super clear