-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
Package
Carbon for IBM Products
Description
When using the Tearsheet with an onClose callback that returns a boolean, the callback seems to capture a stale state value. If onClose returns a value derived from a useState variable, the Tearsheet continues to use the initial state value instead of the most recent one. The state only updates correctly after closing and reopening the Tearsheet.
Component(s) impacted
Tearsheet
Browser
No response
@carbon/ibm-products (previously @carbon/ibm-cloud-cognitive) version
2.78.0
Suggested Severity
None
Product/offering
Glossary
CodeSandbox or Stackblitz example
https://stackblitz.com/edit/github-fadd4uc7-rnv9g4o4?file=src%2FExample%2FExample.jsx
Steps to reproduce the issue (if applicable)
- Open the Stackblitz example
- Press ESC - the tearsheet closes as expected
- Reopen the Terasheet
- Click the button that toggles
Prevent closingtotrue - Press ESC again - the Tearsheet closes (but it sholdn't)
- Reopen the Tearsheet
- Press ESC - only now the Tearsheet doesn't close
Observe the console logs - while pressing ESC, preventClosing value remains stale (initial value)
Release date (if applicable)
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate issues
Metadata
Metadata
Assignees
Type
Projects
Status
Needs triage 🧐