Defer approval bar focus until after CSS transition completes
- SHA
17fd0ff575a16afb87c4ee4d2625908f51b2b821- Parents
-
8cdd374 - Tree
76e6a35
17fd0ff
17fd0ff575a16afb87c4ee4d2625908f51b2b8218cdd374
76e6a35| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/ui/widgets/approval_bar.py
|
17 | 11 |
src/loader/ui/widgets/approval_bar.pymodified@@ -119,25 +119,31 @@ class ApprovalBar(Widget): | ||
| 119 | 119 | preview = preview[:57] + "..." |
| 120 | 120 | preview_label.update(preview) |
| 121 | 121 | |
| 122 | - # Show the bar and focus it | |
| 122 | + # Show the bar and focus it after the CSS transition completes | |
| 123 | 123 | self.add_class("visible") |
| 124 | - self.can_focus = True # Make sure it can receive focus | |
| 125 | - | |
| 126 | - # Debug logging | |
| 127 | - try: | |
| 128 | - with open("/tmp/loader_debug.log", "a") as f: | |
| 129 | - f.write(f"[approval-bar] show_approval: tool={tool_name}, visible=True, focusing...\n") | |
| 130 | - except Exception: | |
| 131 | - pass | |
| 124 | + self.can_focus = True | |
| 132 | 125 | |
| 133 | - self.focus() | |
| 126 | + def _grab_focus() -> None: | |
| 127 | + self.focus() | |
| 128 | + try: | |
| 129 | + with open("/tmp/loader_debug.log", "a") as f: | |
| 130 | + f.write( | |
| 131 | + f"[approval-bar] deferred focus: has_focus={self.has_focus}\n" | |
| 132 | + ) | |
| 133 | + except Exception: | |
| 134 | + pass | |
| 134 | 135 | |
| 135 | 136 | try: |
| 136 | 137 | with open("/tmp/loader_debug.log", "a") as f: |
| 137 | - f.write(f"[approval-bar] focus() called, has_focus={self.has_focus}\n") | |
| 138 | + f.write( | |
| 139 | + f"[approval-bar] show_approval: tool={tool_name}, " | |
| 140 | + f"visible=True, deferring focus...\n" | |
| 141 | + ) | |
| 138 | 142 | except Exception: |
| 139 | 143 | pass |
| 140 | 144 | |
| 145 | + self.call_after_refresh(_grab_focus) | |
| 146 | + | |
| 141 | 147 | def hide_approval(self) -> None: |
| 142 | 148 | """Hide the approval bar.""" |
| 143 | 149 | self.remove_class("visible") |