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

[LIVE-12968][LLM] QueuedDrawer: if onClose changes, drawer shouldn't auto close #7068

Merged

Conversation

ofreyssinet-ledger
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger commented Jun 11, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests. Fully covered by automatic tests, I adapted the existing tests so that they would break without this fix in the same kind of situation as the one detected, and they pass.
  • Impact of the changes:
    • all drawers in LLM

📝 Description

The property onClose was indirectly a dependency of the useEffect that triggers auto closing in some cleanup logic of the QueuedDrawer component.
The solution is to keep onClose in a ref in the component so that it can still be used in that useEffect without triggering the useEffect when its value changes.

before.mp4
after.mp4

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

Copy link

vercel bot commented Jun 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2024 8:19am
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2024 8:19am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2024 8:19am
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2024 8:19am
web-tools ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2024 8:19am

@live-github-bot live-github-bot bot added the mobile Has changes in LLM label Jun 11, 2024
@ofreyssinet-ledger ofreyssinet-ledger changed the title [LIVE-12968][LLM] QueuedDrawers: if onClose changes, drawer shouldn't auto close [LIVE-12968][LLM] QueuedDrawer: if onClose changes, drawer shouldn't auto close Jun 11, 2024
@ofreyssinet-ledger ofreyssinet-ledger marked this pull request as ready for review June 11, 2024 15:01
@ofreyssinet-ledger ofreyssinet-ledger requested a review from a team as a code owner June 11, 2024 15:01
@ofreyssinet-ledger ofreyssinet-ledger changed the base branch from develop to release June 11, 2024 15:05
@ofreyssinet-ledger ofreyssinet-ledger requested review from a team as code owners June 11, 2024 15:05
@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-12968-drawer-closing-immediately branch from d49b971 to 17ad40e Compare June 11, 2024 15:07
Copy link
Member

@KVNLS KVNLS left a comment

Choose a reason for hiding this comment

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

LGTM! I tested the app and it works well! Thanks!

Comment on lines +93 to +94
onCloseRef.current && onCloseRef.current(); // hack to avoid triggering the useEffect below if the parent changes the onClose prop
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

No problem with the hack here, just pointing out that they recently talked about useEvent for this kind of scenario
https:/reactjs/rfcs/blob/useevent/text/0000-useevent.md
facebook/react#14099

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aaah interesting !

@ofreyssinet-ledger ofreyssinet-ledger force-pushed the bugfix/LIVE-12968-drawer-closing-immediately branch from 17ad40e to 852b109 Compare June 12, 2024 08:18
@ofreyssinet-ledger ofreyssinet-ledger merged commit aae9b45 into release Jun 12, 2024
25 of 30 checks passed
@ofreyssinet-ledger ofreyssinet-ledger deleted the bugfix/LIVE-12968-drawer-closing-immediately branch June 12, 2024 08:23
ofreyssinet-ledger added a commit that referenced this pull request Jun 12, 2024
…ng-immediately-develop

fix(llm/QueuedDrawer): QueuedDrawer shouldn't auto close (cherrypick of #7068 for develop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Has changes in LLM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants