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: Conditionally render TabPanel under TabView #4235

Closed
maitrungduc1410 opened this issue Apr 8, 2023 · 6 comments · Fixed by #4236
Closed

TabView: Conditionally render TabPanel under TabView #4235

maitrungduc1410 opened this issue Apr 8, 2023 · 6 comments · Fixed by #4236
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@maitrungduc1410
Copy link

maitrungduc1410 commented Apr 8, 2023

Describe the bug

There's a bug when conditionally render TabPanel under TabView.

Let say:

<TabView>
  <TabPanel header="test 1">
    Hello World
  </TabPanel>
  <TabPanel header="test 2">
    Hello World
  </TabPanel>
  {someCondition && (
    <TabPanel header="test 3">
      Some content
    </TabPanel>
  )}
</TabView>

I figure out that when checking props.children for a Tabview, it returns false for the third tab, but PrimeReact doesn't filter this value and consider it's valid React Node then process rendering that node:

Screenshot 2023-04-08 at 12 26 41 PM

Reproducer

No response

PrimeReact version

9.1.1

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@maitrungduc1410 maitrungduc1410 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 8, 2023
melloware added a commit to melloware/primereact that referenced this issue Apr 8, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 8, 2023
@melloware melloware self-assigned this Apr 8, 2023
@melloware melloware added this to the 9.2.3 milestone Apr 8, 2023
@melloware
Copy link
Member

Thanks for the report. Check out my PR. since the tab can be false i simple check that value first before anything else.

@maitrungduc1410
Copy link
Author

maitrungduc1410 commented Apr 20, 2023

Hi @melloware , I just found a bug regarding type error of the tab view:
after upgrading to "primereact": "^9.3.0", this 3 props are now required closeIcon, nextButton, prevButton. even If their type has undefined, but they're not annotated with ? that's why compiler doesn't understand that they're optional. Before it was fine without the 3 props

Screenshot 2023-04-20 at 10 11 23 PM

Screenshot 2023-04-20 at 10 13 22 PM

Screenshot 2023-04-20 at 10 11 11 PM

@maitrungduc1410
Copy link
Author

When I provide the 3 props, it's fine

Screenshot 2023-04-20 at 10 11 34 PM

@maitrungduc1410
Copy link
Author

This is error when I build my project (nextjs):

Screenshot 2023-04-20 at 10 17 01 PM

@melloware
Copy link
Member

Yea the fix has been merged but not yet released. It should be in 9.3.1 you are using 9.3.0 right?

@maitrungduc1410
Copy link
Author

Yes, I'm using 9.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants