Problem/Motivation

Applying the states API to a vertical tab removes the tab content, but not the link in the vertical tab menu:

Steps to reproduce:

$form['toggle_visible'] = array(
      '#type' => 'checkbox',
      '#title' => $this->t('Toggle visibility'),
      '#default_value' => FALSE,
    );
    $form['vertical_tabs1'] = array(
      '#type' => 'vertical_tabs',
      '#default_tab' => 'edit-details1',
    );
    $form['details1'] = array(
      '#type' => 'details',
      '#title' => $this->t('details1'),
      '#open' => TRUE,
      '#group' => 'vertical_tabs1',
      '#states' => array(
        'visible' => array(
          'input[name=toggle_visible]' => array('checked' => FALSE),
        ),
      ),
    );

Proposed resolution

Make states apply to the vertical tab and update the vertical tab menu accordingly.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

States are applied to the vertical tab and update the vertical tab menu accordingly.

API changes

To be determined.

Data model changes

None.

Original report by Berdir:

See #767212-12: #states can't hide/show fieldsets.

The attached patch fixes it, it's probably a bit hackish, but that was the best I could come up with my limited JS skills :)

What it does is add a derived id (based on the fieldset id) to each vertical tab li element. Then it overrides the state:visibile handler for those fieldsets and instead hides/shows the corresponding button. It also switches back to the nearest fieldset if it is currently active when hidden again.

I guess it might be possible to pass the vertical_tab element somehow directly to that bind callback, which would make that id stuff unecessary.

CommentFileSizeAuthor
#91 1148950-91.patch1.36 KBandreastkdf
#89 1148950-nr-bot.txt9 KBneeds-review-queue-bot
#88 1148950-88.patch1.36 KB_utsavsharma
#87 1148950-86-reroll-9.5.patch3.61 KBseanb
#85 1148950-86-reroll-9.4.patch3.24 KBseanb
#81 1148950-81-claro.patch3.29 KBaskibinski
#80 interdiff-1148950-78-80.txt1.88 KBcilefen
#80 1148950-80.patch4.37 KBcilefen
#78 interdiff-1148950-75-78.txt578 bytescilefen
#78 1148950-78.patch4.59 KBcilefen
#77 1148950-75.patch4.59 KBcilefen
#74 1148950-74.patch5.23 KBseanb
#66 1148950-66.patch4.81 KBidebr
#64 1148950-64.patch4.8 KBmanuel garcia
#64 interdiff-1148950-62-64.txt2.41 KBmanuel garcia
#62 interdiff-59-62.txt1.08 KBseanb
#62 1148950-62.patch4.82 KBseanb
#59 1148950-59-reroll-54-8.6-8.5.patch4.82 KBseanb
#56 interdiff-1148950-56.txt1.67 KBzahord
#56 1148950-56.patch1.67 KBzahord
#54 1148950-54.patch4.83 KBGrandmaGlassesRopeMan
#54 interdiff-1148950-50-54.txt3.8 KBGrandmaGlassesRopeMan
#50 1148950-50.patch4.26 KBmanuel garcia
#47 vertical_tabs_states_test.zip2.61 KBmanuel garcia
#47 1148950-47.patch4.26 KBmanuel garcia
#44 states-vertical-tab-summary.gif21.24 KBidebr
#40 vertical_tabs_states_test.tar_.gz1.44 KBmanuel garcia
#39 interdiff.txt1.44 KBmanuel garcia
#39 states_doesn_t_work-1148950-39.patch2.26 KBmanuel garcia
#35 interdiff-1148950-31-35.txt2.95 KBmbrc
#35 make-states-work-for-vertical-tabs-1148950-35.patch2.59 KBmbrc
#31 interdiff.txt766 bytesmanuel garcia
#31 states_doesn_t_work-1148950-31.patch2.39 KBmanuel garcia
#25 make-states-work-for-vertical-tabs-1148950-25.patch2.38 KBlucastockmann
#18 make-states-work-for-vertical-tabs-1148950-18.patch2.42 KBdealancer
#10 make-states-work-for-vertical-tabs-1148950-10.patch2.38 KBanon
#9 vertical-tabs-states-invisible-707484-9.patch1.21 KBJohnny vd Laar
#6 make-states-work-for-vertical-tabs-1148950-6.patch1.21 KBanon
make_states_work_for_vertical_tabs.patch2.25 KBberdir

Comments

berdir’s picture

Issue tags: +FAPI #states

Tagged.

sun’s picture

I fear the "select another vertical tab" logic is not necessarily complete - I had similarly simple code in filter.admin.js in the beginning, but thorough manual testing revealed lots of bugs with that. Of course, filter.admin.js doesn't use #states, but the active vertical tab logic should be comparable.

berdir’s picture

I'll check that out.

I've only tested it with having a fieldset in the middle and with having one in the beginning, and it worked fine for me.

BenK’s picture

Subscribing

anon’s picture

Subscribing

anon’s picture

@Sun, What do you think of this patch?
Its from D7 dev.

anon’s picture

Version: 8.x-dev » 7.x-dev

Changed the Drupal verison, if this isnt ok, then please change it back.

Johnny vd Laar’s picture

The patch breaks the functionality to assign menu's to nodes.

Johnny vd Laar’s picture

This patch solves the problem by looking into the e.target

anon’s picture

This patch is the same as in #9 but it also hides the wrapping div when no fieldsets are visible.

berdir’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

This needs to be fixed in 8.x first, and then backported.

fenda’s picture

Looking to sponsor someone to get this fixed in D8 and back ported to D7. Message me off interested!

nod_’s picture

need D8 reroll and use e.preventDefault(); instead of return false;

cweagans’s picture

wim leers’s picture

Component: javascript » forms system
Issue tags: +JavaScript

Bump, would be nice to have this fixed in D8 :)

wim leers’s picture

dealancer’s picture

Issue summary: View changes

I've tried patch #10. It works, however when the verical tab is shown it also gets focus, which should not happen. This is because tabShow() is called which does focus: "this.focus();".

dealancer’s picture

Version: 8.0.x-dev » 7.x-dev
StatusFileSize
new2.42 KB

Here is re rolled patch which fixes problem described in #17.

dealancer’s picture

Version: 7.x-dev » 8.1.x-dev

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

josephdpurcell’s picture

This patch appears to work correctly. I can confirm that by adding a vertical tab with config like:

    '#states' => array(
      'visible' => array(
        ':input[name="scheme"]' => array('value' => 'private'),
      ),
    ),

The tab is hidden.

I have a few nit picks:

  1. +++ b/misc/vertical-tabs.js
    @@ -26,7 +27,16 @@ Drupal.behaviors.verticalTabs = {
    +      tab_pane_set.wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list)
    

    Perhaps more readable would be:

    this_pane_set
      .wrap(...)
      .before(...)
      .bind(..);
    

    Similar to line ~49.

  2. +++ b/misc/vertical-tabs.js
    @@ -38,6 +48,27 @@ Drupal.behaviors.verticalTabs = {
    +                // Get the corresponding vertical_tab button.
    

    This comment is either obscure, or misplaced.

josephdpurcell’s picture

Issue tags: +Dublin2016

This is a small-ish chunk of work that someone could sprint on today.

lucastockmann’s picture

Assigned: Unassigned » lucastockmann

Working on this in dublin.

lucastockmann’s picture

Re-rolled this patch. Also followed comments #13 and #22.

Tested with this snippet:

'#states' => array(
  'visible' => array(
    ':input[name="user_email_verification"]' =>  array('checked' => FALSE)
  ),
),
lucastockmann’s picture

Assigned: lucastockmann » Unassigned
Status: Needs work » Needs review

The last submitted patch, 18: make-states-work-for-vertical-tabs-1148950-18.patch, failed testing.

steffenr’s picture

Assigned: Unassigned » steffenr

I'll have a look on your patch luca.

steffenr’s picture

Assigned: steffenr » Unassigned
Status: Needs review » Reviewed & tested by the community

Looks fine for me - i did some testing with a custom field to hide/show the "Advanced" field section on the node form.

Thx luca.

manuel garcia’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/misc/vertical-tabs.js
@@ -53,7 +54,19 @@
+          .bind('updateTabPaneSet', function() {
+          var tab_set = tab_pane_set.parent();
+          tab_set.show();
+          var $fieldsets = $('> fieldset:visible', this);
+          if ($fieldsets.length == 0) {
+              tab_set.hide();
+            }

Indentation is off here

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new2.39 KB
new766 bytes

Fixing #30.

As a side note, core includes a .editorconfig file, which you can use to help prevent indentation issues in the future =) - just install http://editorconfig.org/#download for your IDE of choice and you'll be all set.

droplet’s picture

Component: forms system » markup
Status: Needs review » Needs work
Issue tags: +Needs JavaScript testing

We already used jQuery inside the script, let use jQuery.on and adding the namespace to the event.



+++ b/core/misc/vertical-tabs.js
@@ -43,6 +43,7 @@
+        var tab_pane_set = $(this);

$tabPaneSet

droplet’s picture

Component: markup » javascript
mbrc’s picture

Assigned: Unassigned » mbrc
Issue tags: +drupalironcamp2016
mbrc’s picture

Assigned: mbrc » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.59 KB
new2.95 KB

Notes:

  • Fixed #31.
  • Changed "fieldset" to "pane" or "vertical tab", depending on the context.
  • Only use tabHide() to hide the tab if it's currently active/visible. If we're hiding an inactive tab, we just need to hide the tab title. This way we prevent the unwanted refocusing of tabs.
  • Use stopPropagation() instead of preventDefault() to prevent bubbling.
mbrc’s picture

Title: #states doesn't work for vertical tab fieldsets » #states doesn't work for vertical tabs

Removing "fieldsets" from the title, since in D8 we're not using them anymore to create vertical tabs.

nod_’s picture

Status: Needs review » Needs work

+ var $tabPaneSet = $(this);

we alreday have $this defined earlier, do we need this new variable?

Also I'm really not looking forward to having #states code outside states.js. Can we at least separate this callback in a differnet file, verticaltabs.states.js for exemple? I'd feel better.

manuel garcia’s picture

Assigned: Unassigned » manuel garcia
manuel garcia’s picture

Assigned: manuel garcia » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.26 KB
new1.44 KB

Simple one, just addressing + var $tabPaneSet = $(this);

Still needs work based on #37.

manuel garcia’s picture

Status: Needs review » Postponed (maintainer needs more info)
StatusFileSize
new1.44 KB

While working on this, I've found that this is already working fine on 8.3.x at least.

I have built a test module for this purpose, which you can find attached. It sets up a form with a few different use cases, different states and it seems fine even on nested vertical tabs.

I haven not been able to find any steps to reproduce this problem so I am postponing this issue for now, feel free to check out the attached module to double check.

manuel garcia’s picture

Re #40 just enable the module and go to /vertical_tabs_states_test/form/default

navneet0693’s picture

I am not able to reproduce it ! The module upload by @Manuel is working without problem, even examples VerticalTabsDemo, http://cgit.drupalcode.org/examples/tree/fapi_example/src/Form works fine.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

idebr’s picture

Title: #states doesn't work for vertical tabs » Applying #states to a vertical tab does not update the vertical tabs menu
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new21.24 KB

I can confirm the states API works for #type => vertical_tabs, but not #type => details, see the screen capture in the updated issue summary.

manuel garcia’s picture

Thanks @idebr for the report, can you share here the code to see/troubleshoot the bug please?

idebr’s picture

Hey Manuel,

I updated the test module you supplied in #40 and moved the states to the details. The code I changed is available in the issue summary

manuel garcia’s picture

StatusFileSize
new4.26 KB
new2.61 KB

Rerolling #39 due to #2818825: Rename all JS files to *.es6.js and compile them .

I now see what you mean @idebr, and you're right, that doesn't work at the moment, so thanks a LOT for following up on this!
So yes we do need to fix this.

One thing to note is that for the optional state, you actually have to use it on the input fields themselves, doesn't work if you use it on details, not sure if this is a bug we should fix as well, or if its ok to be like this. The rest of the states changes do work on details with the patch applied though.

I attach the updated module to test the states on details, and also showing that last bit I mention about optional states (enable and go to /vertical_tabs_states_test/form/default)

manuel garcia’s picture

Some more findings, toggling enabled on details works without the patch on #47.

So so far the ones not working without the patch that I know of are:

  • visibility (elements inside the details element do get hidden, but the tab itself remains visible)
  • optional on details

With the patch applied, still not working:

  • optional on details

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manuel garcia’s picture

StatusFileSize
new4.26 KB
robpowell’s picture

#50 worked for me. Disregard, wrong page.

markhalliwell’s picture

Status: Needs review » Reviewed & tested by the community

I can verify that this fixes the issue. I thought I was configuring the #states array incorrectly or missing some "special case" since it was vertical tabs. Glad to know this is actually a bug. I have to say though, this is a pretty big bug and the priority should probably be escalated and backport patches be made.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for working on this!

The current fix introduces a few errors in our JS coding style rules. Before:

Errors:
==============================
no-use-before-define: 75
max-len: 70
camelcase: 65
no-restricted-syntax: 54
no-shadow: 42
new-cap: 18
default-case: 16
no-continue: 9
no-new: 9

With patch:

Errors:
==============================
no-use-before-define: 75
max-len: 70
camelcase: 66
no-restricted-syntax: 54
no-shadow: 42
new-cap: 18
default-case: 16
no-new: 9
no-continue: 9
no-var: 3
vars-on-top: 2
eqeqeq: 2
space-before-funct
ion-paren: 1
indent: 1
keyword-spacing: 1

Reference: #2912962: Step 1 JS codestyle: [meta] Fix JS coding standards in core

We probably also need an automated test that will ensure the bug stays fixed. Thanks!

GrandmaGlassesRopeMan’s picture

Status: Needs work » Needs review
StatusFileSize
new3.8 KB
new4.83 KB

- Fixes coding standards issues.

droplet’s picture

Status: Needs review » Needs work
+++ b/core/misc/vertical-tabs.es6.js
@@ -72,7 +72,19 @@
+          .on('updateTabPaneSet', () => {

Can we have a better name and with namespacing?

+++ b/core/misc/vertical-tabs.es6.js
@@ -88,6 +100,31 @@
+              if (e.target === this && e.trigger) {

in what case, "e.target != this" ?

+++ b/core/misc/vertical-tabs.es6.js
@@ -88,6 +100,31 @@
+                  if (!e.value) {
...
+                  else if (e.value) {

can we add some comments to show what this condition trying to do?

+++ b/core/misc/vertical-tabs.es6.js
@@ -72,7 +72,19 @@
+            tabSet.show();
+            const $panes = $('> details:visible', this);
+            if ($panes.length === 0) {

any better way to skip $.show? can we verify it in another non-DOM manipulation way? Thanks.

** Missing tests

zahord’s picture

StatusFileSize
new1.67 KB
new1.67 KB

Hi all,

I was checking the issue and send an update with a different approach just updating the vertical-tab title to set the same status and allow the default behavior for the status works and trying to affect less vertical-tabs js.

I hope this works!

Regards.

zahord’s picture

Status: Needs work » Needs review

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

seanb’s picture

StatusFileSize
new4.82 KB

Rerolled #54 for 8.5 and 8.6 (patch applies to both).

Status: Needs review » Needs work

The last submitted patch, 59: 1148950-59-reroll-54-8.6-8.5.patch, failed testing. View results

seanb’s picture

*edit* Commented on wrong issue, sorry...

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new4.82 KB
new1.08 KB

I missed a small change. Think this should fix it.

askibinski’s picture

Status: Needs review » Needs work

It seems the cody style was changed to camelCase in #2915784: 1/3 JS codestyle: camelcase.

vertical_tab -> verticalTab

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB
new4.8 KB

Thanks for the heads up @askibinski addressing #63 here.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

idebr’s picture

StatusFileSize
new4.81 KB

Reroll against 8.7.x after #2981652: [Aug. 9 2018] Format core JavaScript using recently add Prettier was committed.

Still needs an automated JavaScript test.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

manuel garcia’s picture

Status: Needs review » Needs work

Setting to needs work to address #55 and for adding test coverage.

gease’s picture

To me, patch in #66 doesn't fix the issue. It hides a tab when it is inactive, but for an active (open) tab, it hides the tab, but the content doesn't change. Imho, in case of hiding an active tab, it should be hidden with its content and default tab should be made active (content displayed and the tab itself should be selected).

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

seanb’s picture

Issue tags: -JavaScript +JavaScript
StatusFileSize
new5.23 KB

Reroll for 9.1.x

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new4.59 KB

A reroll of #74 for 9.3.x.

cilefen’s picture

StatusFileSize
new4.59 KB
new578 bytes

Fix the code style.

cilefen’s picture

#78 applies but wrongly hides vertical tabs for us in the situation described in this issue so I think it needs work.

cilefen’s picture

StatusFileSize
new4.37 KB
new1.88 KB

I think that this became bound to the wrong value with the changes due to deprecating jquery.once.

Claro theme has a copy of this JavaScript and will need to be changed too.

askibinski’s picture

StatusFileSize
new3.29 KB

@cilefen
Your patch at #80 causes an undefined variable "verticalTab".

You are right though that Claro has a mostly identical copy of these js, except for some classnames I think. So I created a patch based on #78 for Claro, since most people are probably going to use Claro or Gin these days. Not sure if this issue needs splitting for that, because eventually I believe the Claro override js will be removed when #3081489: Remove duplicate code from veritcal-tabs.js in Claro is implemented. So, an alternative would be to work on that issue, create a core patch for that and then use the patch for misc/js.

I also stripped the "If there are no visible tab panes, hide the whole vertical-tabs area" part since it adds a bit of fragile code and the current approach left me with a lot of leftover styling/classes in Claro (when using vertical tabs with field_group) which maybe could better be handled in a separate ticket.

Also also, I created a similar patch for when horizontal tabs are used with the field_group module: #3264569: Support applying #states to a horizontal tab

adrianliegmann’s picture

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cilefen’s picture

Status: Needs review » Needs work

So I think for this to be commit-able we need patches for the plain and Claro files.

seanb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.24 KB

All duplicate claro code has been removed in #3081489: Remove duplicate code from veritcal-tabs.js in Claro. Rerolled the patch for 9.4.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

seanb’s picture

StatusFileSize
new3.61 KB

Another reroll for 9.5.

_utsavsharma’s picture

StatusFileSize
new1.36 KB

Reroll for 10.1.x.
Please review.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new9 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andreastkdf’s picture

StatusFileSize
new1.36 KB

Reroll for 10.2.x

chili.hh’s picture

The patch from #91 works as far as #states are usable for vertical tabs. However, with Drupal v10.4.0 I currently encounter the problem, that the initial state of impacted tabs is not set correctly. In other words, in my form I have a checkbox that should determine if a tab menu entry for a tab should be visible as long as the checkbox is actually checked. If the initial state of the checkbox is unchecked, the corresponding tab menu entry still get displayed nevertheless until I uncheck and re-check the controlling checkbox. The initial display of the tab contents works though (so, the to be conditionally displayed tab contents itself is NOT visible - it's just the menu entry in the tab menu).

It seems to me as if only the visibility state of the tab menu entry is set wrong for the initial state and it's not a fault of the controlling checkbox/form element. Why do I think that? Because in the tab that is to be conditionally displayed (for which the menu entry should NOT be visible, but is indeed accessible and therefore one can navigate to the tab contents) there are form elements contained that should receive a "required" flag when the same checkbox that is controlling the tab visibility is checked - and this works. In the initial state (so, when the tab itself is wrongly displayed) the dependant form elements within that tab are NOT required and only get required once the checkbox is actually ticked.

Unfortunately I was not able to spot the code fragment that's responsible for the state initialization and therefore can't provide an updated patch. :-(

// edit:
I just realized that the patch from #91 ist NOT code fragment causing the problem! On line 92 of the vertical-tabs script there is the command "tabList.append(verticalTab.item);" that unconditionally adds a menu entry to the tab menu. This should only get done conditionally...

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.