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

PanelStack2: Prevent extra render due to updated previous panel #6713

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

YoruNoHikage
Copy link
Contributor

Hi,

I had a TextArea component with a jumping cursor from the moment I updated to Blueprint 5 from 4.

This component is located in a second panel within a PanelStack2 but the first one had changing props at every render.
When digging through the differences between v4 and v5, I found out that handleClose has been added to the useMemo dependencies of PanelWrapper triggering a render every time previousPanel changes.

So for now, to go around this, I wrap the previous panel with a useMemo as well.

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Extracting previousPanel !== undefined outside the callback prevent extra renders by using a boolean instead.

When the previous panel changes, this updates `handleClose`, triggering a new render of the panel wrapper.
This commit makes it only happen when the previous panel has been removed or added.
@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @YoruNoHikage! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@ericjeney ericjeney merged commit 4f034db into palantir:develop Apr 19, 2024
12 checks passed
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.

None yet

4 participants