prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Dialog modal=True doesn't seem to work

Open
#1,476 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

I'm attempting to use Dialog in a modal manner inside a full screen application where I've already bound things, such as @kb.add('o'). When I create the Dialog, I add in modal=True to the arguments. However, when I trigger this dialog to display, those key bindings (such as o) are still sucked up and the dialog doesn't behave like a modal.

 39     dialog = Dialog(
 40         title=title,
 41         body=HSplit(
 42             [
 43                 Label(text=text, dont_extend_height=True),
 44                 textfield,
 45                 ValidationToolbar(),
 46             ],
 47             padding=Dimension(preferred=1, max=1),
 48             modal=True
 49         ),
 50         buttons=[ok_button, cancel_button],
 51         with_background=True,
 52         modal=True
 53     )

Further, dialog.container.container.is_modal() evaluates to False with these parameters.

Not sure what to do at this point as the base key bindings (which I would like to keep) interfere with simple typing into the box.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Dialog construction with modal=True alongside the existing @kb.add('o') binding. Inspect the Dialog/container path and check why dialog.container.container.is_modal() is false. Done means the modal dialog accepts text without the base key bindings consuming those keystrokes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.