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

TabView: onTabChange + activeIndex styling issues with unstyled mode + Tailwind. #7043

Closed
eklee opened this issue Aug 13, 2024 · 7 comments · Fixed by #7057
Closed

TabView: onTabChange + activeIndex styling issues with unstyled mode + Tailwind. #7043

eklee opened this issue Aug 13, 2024 · 7 comments · Fixed by #7057
Assignees
Labels
Component: Tailwind Tailwind specific issue
Milestone

Comments

@eklee
Copy link

eklee commented Aug 13, 2024

Describe the bug

Tabview controlled mode partially works with unstyled + Tailwind styling. Clicking on tabs will change the tab panel content, but the active highlight seems to be stuck on the initial state of activeIndex.

Reproducer

https://stackblitz.com/edit/q1g8yj-xluy87

System Information

PrimeReact version
10.8.2

React version
18.x

Language
TypeScript

Build / Runtime
Vite

Browser(s)
Chrome 127

Steps to reproduce the behavior

Goto this Stackblitz project - https://stackblitz.com/edit/q1g8yj-xluy87 - click on the Theme and Language tabs, notice the tab content changes, but the tab itself always have active highlight on the first tab, even after you click on the 2nd tab.

Expected behavior

Adding onTabChange callback handler should not stop tab switching from working

@eklee eklee added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 13, 2024
@melloware
Copy link
Member

melloware commented Aug 13, 2024

@eklee by design see the Controlled demo: https://primereact.org/tabview/#controlled

Once you start using ontabChange you have now switched to Controlled mode and must track the activePage yourself.

@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 13, 2024
@eklee eklee changed the title TabView: After adding onTabChange callback handler, can't change active tab anymore TabView: onTabChange + activeIndex styling issues with unstyled mode + Tailwind. Aug 13, 2024
@eklee
Copy link
Author

eklee commented Aug 13, 2024

@melloware - it does look like onTabChange + activeIndex works on styled template. But it seems to be partially working on unstyled + Tailwind. With unstyled + Tailwind, clicking on tabs do change the tab content, but the active tab highlight does not change. I have created another fork here: https://stackblitz.com/edit/q1g8yj-xluy87 and updated the bug description.

An example is this: the content is showing language, but the tab highlight is stuck on Theme.
image

@melloware melloware added Component: Tailwind Tailwind specific issue and removed Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior labels Aug 13, 2024
@melloware
Copy link
Member

Ok if it's tailwind related is it this issue: #6868

@melloware
Copy link
Member

Fixed with @gcko PR #7057

@onn-software
Copy link
Contributor

Hey, I can see it's closed, and perhaps I should open a new issue. But I'm using unstyled + tailwind as well, and encounter the same issue. After upgrading to 10.8.3 the tabs crash:

TypeError: Cannot read properties of undefined (reading 'state') at headerAction (index.esm.js:297:213)

When I change te be resilient against undefined, the tab UI does not reflect active state

'border-gray-300 bg-white text-gray-700 hover:bg-white hover:border-gray-400 hover:text-gray-600 dark:bg-gray-900 dark:border-blue-900/40 dark:text-white/80 dark:hover:bg-gray-800/80': parent?.state.activeIndex !== context?.index,

The reproduction for me is as easy as this, it will crash immediatly.

<PrimeReactProvider
              value={{ unstyled: true, pt: Tailwind, ripple: true }}
            >
    <TabView>
        <TabPanel header='A'>A</TabPanel>
        <TabPanel header='B'>B</TabPanel>
    </TabView>
</PrimeReactProvider>

@onn-software
Copy link
Contributor

I'll make a proper bug later today

@gcko
Copy link
Contributor

gcko commented Sep 18, 2024

I fixed this just 30 minutes ago it is tied to #7201 - pr #7212

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

Successfully merging a pull request may close this issue.

4 participants