The project has a small draft preview panel. After a recent change, it started behaving unreliably when opening and closing. You need to perform a code review and find two independent bugs.
open flag, draft text, and an onClose callback.draft text.draft changes later while the panel is visible, the preview must update too.Escape must close exactly the currently open panel.Open preview button.Escape, then open the panel again several times.onClose calls in the console.Change draft while open.textarea with the text in the Preview block.Escape key press triggers onClose once.Preview block always shows the current draft value while the panel is open.19.0.05.8.xStrictMode during development and in normal production modeonClose may change parent state and write to consoleUse line comments to explain the problem, its impact, the fix and how to test it.