Opened 7 years ago

Closed 7 years ago

#8568 closed bug (fixed)

jQuery ui tabs: wrong default active li if ul contains extraneous elements

Reported by: erethnor Owned by:
Priority: minor Milestone: 1.9.1
Component: ui.tabs Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:

Description

You can see the problem on this jsFiddle.

There, the second tab is selected by default, when the first should be active instead.

This is caused by this line:

active = this.tabs.eq( active ).index();

replacing it with the line below fixes the problem:

active = this.tabs.index( this.tabs.eq( active ) );

Please do not disregard this as not a bug because there shouldn't be a LI without a A there anyway; in my case the extraneous elements are created by css3pie and I cannot feasibly move them out of the UL.

Change History (5)

comment:1 Changed 7 years ago by Scott González

Resolution: fixed
Status: newclosed

Tabs: Account for non-tab list items on init. Fixes #8568 - jQuery ui tabs: wrong default active li if ul contains extraneous elements.

Changeset: 7023ed4699b0c52e253ba2b3949d08b3dac2905b

comment:2 Changed 7 years ago by Scott González

Milestone: 1.9.0git

comment:3 Changed 7 years ago by erethnor

This needs to be reopened as there is a very similar problem when using the ui-tabs-active class to mark one tab as active via HTML on load.

This line:

active = this.tabs.filter( ".ui-tabs-active" ).index();

Should be:

active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );

I tried to browse the code to check if there is more code using .index() not strictly enough but couldn't see any - maybe worth a watch from somebody knowing the code more though?

comment:4 Changed 7 years ago by Scott González

Milestone: git1.9.1
Resolution: fixed
Status: closedreopened
Version: 1.9.0-rc.11.9.0

comment:5 Changed 7 years ago by Scott González

Resolution: fixed
Status: reopenedclosed

Tabs: Handle extraneous list items when using ui-tabs-active to set the initially active tab. Fixes #8568 - jQuery ui tabs: wrong default active li if ul contains extraneous elements.

Changeset: fa62f21e5ad09e5368efc3079859730e23a7123b

Note: See TracTickets for help on using tickets.