Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Tabs, Carousel, Accordion state #319

Open
bestguy opened this issue Jun 26, 2021 · 1 comment
Open

Simplify Tabs, Carousel, Accordion state #319

bestguy opened this issue Jun 26, 2021 · 1 comment
Labels
Type: Bug Something isn't working Type: Refactor Enhancements, deletions, etc. to existing code

Comments

@bestguy
Copy link
Owner

bestguy commented Jun 26, 2021

All three components do similar things (show one at a time out of many), but each have different approaches to controlling this:

Carousel uses activeIndex
Accordion uses active on AccordionItem
TabContent requires tabId on TabPane

Accordion & TabContent also don't let you control externally..

@dysfunc dysfunc added Type: Refactor Enhancements, deletions, etc. to existing code and removed enhancement labels Nov 12, 2022
@nikolas
Copy link

nikolas commented Dec 8, 2022

Yeah, I'm having trouble setting the active tab dynamically. I have something like this set up:

<script>
let activeTab = 'polls';

const onClickBroadcastPoll = function() {
    activeTab = 'responses';
};
</script>

<TabPane tabId="polls" tab="Polls" active={activeTab === 'polls'}>
</TabPane>
<TabPane tabId="responses" tab="Responses" active={activeTab === 'responses'}>
</TabPane>

And the active tab doesn't update when the activeTab variable updates via user input. Looking at the source code, I can see why - the active variable is only used onMount:

  onMount(() => {
    if (active) setActiveTab(tabId);
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working Type: Refactor Enhancements, deletions, etc. to existing code
Projects
None yet
Development

No branches or pull requests

3 participants