Skip to content

Commit

Permalink
fix: do not focus on tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Aug 23, 2023
1 parent 984f01c commit 6283539
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/harlequin/tui/components/code_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from textual.binding import Binding
from textual.css.query import NoMatches
from textual.message import Message
from textual.widgets import ContentSwitcher, TabbedContent, TabPane
from textual.widgets import ContentSwitcher, TabbedContent, TabPane, Tabs
from textual_textarea import TextArea
from textual_textarea.key_handlers import Cursor
from textual_textarea.serde import serialize_lines
Expand Down Expand Up @@ -55,6 +55,7 @@ async def on_mount(self) -> None:
self.border_title = "Query Editor"
self.add_class("hide-tabs")
await self.action_new_buffer()
self.query_one(Tabs).can_focus = False

def on_focus(self) -> None:
self.current_editor.focus()
Expand All @@ -77,6 +78,7 @@ def on_tabbed_content_tab_activated(
) -> None:
message.stop()
self.post_message(self.EditorSwitched(active_editor=None))
self.current_editor.focus()

async def action_new_buffer(self) -> None:
self.counter += 1
Expand Down
3 changes: 3 additions & 0 deletions src/harlequin/tui/components/results_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
LoadingIndicator,
TabbedContent,
TabPane,
Tabs,
)
from textual.worker import Worker, WorkerState

Expand Down Expand Up @@ -72,6 +73,7 @@ def on_mount(self) -> None:
self.border_title = "Query Results"
self.current = self.TABBED_ID
self.tab_switcher = self.query_one(TabbedContent)
self.query_one(Tabs).can_focus = False

def on_focus(self) -> None:
self._focus_on_visible_table()
Expand All @@ -93,6 +95,7 @@ def on_tabbed_content_tab_activated(
id_ = maybe_table.id
assert id_ is not None
self.border_title = f"Query Results {self._human_row_count(self.data[id_])}"
maybe_table.focus()

def action_switch_tab(self, offset: int) -> None:
if not self.tab_switcher.active:
Expand Down

0 comments on commit 6283539

Please sign in to comment.