textual
textual copied to clipboard
Unable to switch tabs in TabbedContent using a key binding
So I have this annoying issue. I haven't pulled it down to a minimum example, as the area is poorly documented and it may be a user error. The only relevant points are that fills-search
and txs-search
are Input
widgets and that ctrl+f
and ctrl+t
are bindings.
So I have this test:
# part A
await pilot.press("ctrl+f")
await pilot.click('#fills-search')
await pilot.press("s", "h")
assert app.get_widget_by_id('fills-data', DataTable).get_cell_at((0,2)).strip().startswith("Sharks")
# part B
await pilot.press("ctrl+t")
await pilot.click('#txs-search')
await pilot.press("6", ".", "8", "5")
assert app.get_widget_by_id('txs-data', DataTable).get_cell_at((0,2)).strip() == '-6.85'
On the second part, even if I switch part A and B, the pilot.click
function will cause app.screen_stack
to acquire a CommandPalette, which means the get_widget_by_id
is looking at the wrong screen. That is, the app works differently in testing than in execution. I don't know why Textual does this, but I look side-eyed at pilot.py/345
. If I try to work around the problem by adding ENABLE_COMMAND_PALETTE = False
to my app, then it does not bring up the COMMAND_PALETTE, but it stops causing the @on(Input.Changed,...)
to fire. Again, Pilot not working like my app.
Is this a bug or am I using it wrong?