thednp / bootstrap.native

Bootstrap components build with Typescript
http://thednp.github.io/bootstrap.native/
MIT License
1.7k stars 177 forks source link

create a tab should set the first enabled tab to active if needed #432

Closed lekoala closed 2 years ago

lekoala commented 2 years ago

A small difference I've noticed from bs5 is that if you create a tab object, it fails if there are no active class. Obviously you can add them beforehand in js, but it would be nice if the constructor could check if there is an active class or not and make the first tab active (and first tab-pane visible) if needed.

thednp commented 2 years ago

You mean the Tab constructor should check for a all tabs in its parent and set the first one as active, when no active tab is found?

lekoala commented 2 years ago

@thednp exactly ! if your html doesn't have an active class, it will fail because the getActive method will return null. In my use case, i don't set an active class by default in the html because i need to check which tab is active in js (and avoid fouc on initial rendering). Obviously I can add the active class myself first, but it's a nice to have.

thednp commented 2 years ago

If you have the time, go ahead with a PR, and I will provide more guidance / tips on the way.

thednp commented 2 years ago

I think the show() method of Tab need to be reworked, we would need a showTab utility to be used for the new constructor functionality to activate first tab (if none active) on init.

thednp commented 2 years ago

I will implement this feature with the next update. Meanwhile closing the issue due to no activity.