libredb / libredb/libredb-studio
Code Generator modal does not close on Escape while Data Profiler does
- Dominant language
- TypeScript
- Stars
- 726
- Forks
- 119
- Avg merge
- 7h 47m
- Merged PRs (30d)
- 265
Description
## What
The Code Generator modal cannot be closed with Escape. The Data Profiler modal, which uses the same non-Radix shell, had this fixed and handles Escape.
## Where
src/components/CodeGenerator.tsx contains no `Escape` handling and no `onKeyDown` at all.
src/components/DataProfiler.tsx:188-203 documents the same problem being solved for that modal:
```
Escape closes the modal.
...
`ui/dialog`, so nothing bound Escape for it and the header control was the only
exit. Swapping the shell for the Radix primitive would bring Escape along, but
```
So the fix pattern already exists in the repository.
## Expected
Escape closes the Code Generator, the same way it closes the Data Profiler.
## How to fix
Apply the DataProfiler.tsx pattern to CodeGenerator.tsx: mount the key listener only while the modal is open, and unmount it with the modal. Read the comment block at DataProfiler.tsx:188-230 first, it explains why the listener is scoped that way and how it interacts with the shortcuts dialog.
## How to check
Open the Code Generator, press Escape, confirm it closes. Confirm the shortcuts dialog still behaves correctly when both are open.
Contributor guide
Assessment
This issue has not been assessed yet.