We are using quicktab 7.3 version. In one quicktab instance, we have 13 tabs, and we need to hide empty blocks. The render of 'quicktabs' doesn't work for this instance, while the other two render 'accordion' and 'ui_tabs' are working fine.

I figured this issue happens because the way of getting tab index is depending on the order of tab link inside the tab link group.

See js/quicktabs.js

  $ul.find('li a').each(function(i, element){
    element.myTabIndex = i;
}

When we hide the empty tabs, this element.myTabIndex will be wrong. For example, tab0 tab1,tab3 has content, but tab2 doesn't have content. Then for tab3, the table index should be 3, but the current code will get 2 for tab3, because tab2 link has been removed in html structure.

Attached patch works for me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smiletrl’s picture

Status: Active » Needs review
jazzitup’s picture

Status: Needs review » Reviewed & tested by the community

I came across the same issue, tested it and I can confirm the patch fixes the flaw.

gunosov’s picture

Works for me. Thanks!

pramodganore’s picture

Can confirm this works.

FYI: I was using the Phpstorm git patch apply and it does not delete some code and sticks the following code in wrong location.
this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[this.tabIndex];
this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;

I am glad i do a cross check on my patches, this saved me more dev time.

larkydoo’s picture

FileSize
1.92 KB

I wasn't able to get the patch to apply using the patch command. It was unable to find the third Hunk:

- var i = 0;
- for (var key in Drupal.settings.quicktabs[qtKey].tabs) {
- if (i == this.tabIndex) {
- this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[key];
- this.tabKey = key;
- }
- i++;
- }

When I looked at the code, it was actually the following:

var i = 0;
for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
if (i == this.tabIndex) {
this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
this.tabKey = i;
}
}

I'm attaching a patch that should address this issue. It has not been tested, so use at your own risk.

I manually edited the quicktabs.js file using the code in the patch, and it works mahvellously.

Thanks!

Laurie

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: fix_empty_tabs.patch, failed testing.

larkydoo’s picture

RE: Patch failure: My patch is designed to work with quicktabs-7.x-3.6; the original patch should work with quicktabs-7.x-3.x-dev.

jazzitup’s picture

@larkydoo: "Make patches against the -dev version because it is the latest code."

Please always strictly follow the manual: https://www.drupal.org/node/707484

oscaral’s picture

Version: 7.x-3.x-dev » 7.x-3.6
FileSize
1.77 KB

@larkydoo solution works for us for 7.x-3.6 (thanks :) )

martinwrightinfo’s picture

I've tested the patch above (#9) and can confirm that this fixes the problem in 7.x-3.6.

fdefeyter@gmail.com’s picture

I confirm this patch works as well. Why isn't it commited? thx

jazzitup’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 9: fix_empty_tabs.patch, failed testing.

alex_gred’s picture

@smiletrl solution working fine.
Thanks!

gajanannehul’s picture

#9 is working fine.
Thanks!!!

markdc’s picture

I can confirm #9 is working. Thank you.

SocialNicheGuru’s picture

The patch did not apply correctly

patch -p1 < patchfile
patching file js/quicktabs.js
Hunk #1 succeeded at 25 with fuzz 2 (offset 3 lines).
Hunk #2 succeeded at 44 (offset 5 lines).
Hunk #3 FAILED at 69.
1 out of 3 hunks FAILED -- saving rejects to file js/quicktabs.js.rej
> test/sites/test/modules/quicktabs$ more js/*rej
--- js/quicktabs.js
+++ js/quicktabs.js
@@ -69,13 +82,9 @@
this.element = el;
this.tabIndex = el.myTabIndex;
var qtKey = 'qt_' + el.qt_name;
- var i = 0;
- for (var i = 0; i < Drupal.settings.quicktabs[qtKey].tabs.length; i++) {
- if (i == this.tabIndex) {
- this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[i];
- this.tabKey = i;
- }
- }
+ this.tabKey = this.tabIndex;
+ this.tabObj = Drupal.settings.quicktabs[qtKey].tabs[this.tabIndex];
+
this.tabpage_id = 'quicktabs-tabpage-' + el.qt_name + '-' + this.tabKey;
this.container = $('#quicktabs-container-' + el.qt_name);
this.tabpage = this.container.find('#' + this.tabpage_id);

smiletrl’s picture

Version: 7.x-3.6 » 7.x-3.x-dev

You should apply the (original) patch against the latest dev version.

If you fail any patch apply, you can manually edit your code using the change from existing patches, and create a new patch for the change.

4kant’s picture

I too can confirm #9 works for me.
Thanks!

daniel_j’s picture

Re-rolling #9 to apply to latest dev commit.

daniel_j’s picture

Status: Needs work » Needs review
Sebastian Hagens’s picture

#20 works for me