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

check if index of category is out of range #2121

Merged

Conversation

LukasBoll
Copy link
Contributor

closes #2111

@netlify
Copy link

netlify bot commented Mar 21, 2023

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 7a07554
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/6437d68af311a7000893f38a
😎 Deploy Preview https://deploy-preview-2121--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@coveralls
Copy link

coveralls commented Mar 21, 2023

Coverage Status

Coverage: 83.193%. Remained the same when pulling d35500b on LukasBoll:categorisationAndSelection into 229d99a on eclipsesource:master.

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR :) I added a comment on avoiding introducing a useEffect and added a question.

@LukasBoll LukasBoll force-pushed the categorisationAndSelection branch 2 times, most recently from e163756 to d35500b Compare April 11, 2023 11:36
Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The example works well. I added a minor fix suggestion for the new file and added a question.

packages/examples/src/examples/nestedCategorization.ts Outdated Show resolved Hide resolved
{categories.map((_, idx: number) => (
<Tab key={idx} label={tabLabels[idx]} />
))}
</Tabs>
</AppBar>
<div style={{ marginTop: '0.5em' }}>
<MaterialLayoutRenderer {...childProps} />
<MaterialLayoutRenderer {...childProps} key={safeCategory} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for adding this key? I don't think we need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it always makes sense to set a new key and reset the state of all components, as we are working on different data once we change the tap. Also, we could run into similar issues with e.g. the detail list or expandable list, where the old state might not fit to the new data and the selected element is out of range.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it is not strictly necessary because the childProps should change anyway. But we can leave it in as it shouldn't hurt either :D

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, LGTM

{categories.map((_, idx: number) => (
<Tab key={idx} label={tabLabels[idx]} />
))}
</Tabs>
</AppBar>
<div style={{ marginTop: '0.5em' }}>
<MaterialLayoutRenderer {...childProps} />
<MaterialLayoutRenderer {...childProps} key={safeCategory} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it is not strictly necessary because the childProps should change anyway. But we can leave it in as it shouldn't hurt either :D

@lucas-koehler lucas-koehler merged commit ba35fde into eclipsesource:master Apr 13, 2023
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 this pull request may close these issues.

Selection inbetween nested Categorizations may lead to crash
3 participants