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

Controlled Tabs in Panel don't update correctly #3609

Closed
ra-ch-b opened this issue Feb 2, 2024 · 1 comment · Fixed by #3610
Closed

Controlled Tabs in Panel don't update correctly #3609

ra-ch-b opened this issue Feb 2, 2024 · 1 comment · Fixed by #3610

Comments

@ra-ch-b
Copy link

ra-ch-b commented Feb 2, 2024

What version of rsuite are you using?

5.53.0

What version of React are you using?

18.2.0

What version of TypeScript are you using (if any)?

No response

What browser are you using?

Chrome

Describe the Bug

Tabs with controlled state as the child of a Panel don't appear to update correctly. Clicking a tab does not display its associated content, but instead that of the previously active tab.

Expected Behavior

Clicking a tab would update to the associated content.

To Reproduce

import { useState } from 'react';
import { Panel, Placeholder, Tabs } from 'rsuite';

function TestPanel() {
   const [activeKey, setActiveKey] = useState('1');

   const tabs = [
       {
           eventKey: '1',
           title: 'Image',
           content: <Placeholder.Paragraph graph="image" />,
       },
       {
           eventKey: '2',
           title: 'Square',
           content: <Placeholder.Paragraph graph="square" />,
       },
       {
           eventKey: '3',
           title: 'Circle',
           content: <Placeholder.Paragraph graph="circle" />,
       },
   ];

   return (
       <Panel bordered>
           <Tabs activeKey={activeKey} onSelect={setActiveKey}>
               {tabs.map((t) => (
                   <Tabs.Tab eventKey={t.eventKey} key={t.eventKey} title={t.title}>
                       {t.content}
                   </Tabs.Tab>
               ))}
           </Tabs>
       </Panel>
   );
}

With the above component, click through each tab in turn. The displayed content will be that of the previously active tab. From the initial state, clicking the "Square" tab doesn't change the tab content and the image placeholder is still visible. Next, clicking the "Circle" tab displays the square placeholder, which is the content of the previously active "Square" tab and not the expected content of the "Circle" tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants