Skip to content

Dynamic Tab creation doesn't work #474

Open
@nj-vs-vh

Description

@nj-vs-vh

What package has an issue

@svelteuidev/core

A clear and concise description of what the bug is

Trying to create Tabs dynamically doesn't work as expected. In particular, the newly added tab can't be selected with a mouse click, and navigating into it with arrow keys renders tab's content in the header.

In which browser(s) did the problem occur?

Brave (Chromium), Firefox

Steps To Reproduce

Here's the MRE:

<script lang="ts">
  import { Tabs, Stack, Button } from "@svelteuidev/core";

  let tabsContent: number[] = [1, 2, 3];
</script>

<Stack>
  <Button on:click={() => (tabsContent = [...tabsContent, tabsContent.length + 1])}>Add tab</Button>
  <Tabs>
    {#each tabsContent as tab}
      <Tabs.Tab label={tab}>Content: {tab}</Tabs.Tab>
    {/each}
  </Tabs>
</Stack>

When the code above is rendered, the first 3 tabs created initially are working OK, I can switch between them and see Content: N. However, while pressing the Add tab button renders the 4th added tab as expected, I can't click on it. If I navigate into it with arrow keys, the tab's content is rendered inside the tab label (see screenshot)

image

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Relevant Assets

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponentNew or changes to components

    Type

    No type

    Projects

    Status

    Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions