Skip to content

Commit 8f3b193

Browse files
zee-bitneiljp
authored andcommitted
bugfix: ui: Focus on compose area when draft is opened from side-panels.
This commit fixes a bug that caused the focus to not move to the central area if the draft was opened from the side-panels. This is a minor bugfix that helps redirect the focus to the compose area in such cases. The recently added tests for OPEN_DRAFT are amended in this commit to match the added bugfix.
1 parent 0f6aaee commit 8f3b193

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

tests/ui/test_ui.py

+2
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def test_keypress_autohide_streams(self, view, mocker, autohide, key, widget_siz
344344
)
345345
@pytest.mark.parametrize("key", keys_for_command("OPEN_DRAFT"))
346346
def test_keypress_OPEN_DRAFT(self, view, mocker, draft, key, widget_size):
347+
view.body = mocker.Mock()
347348
view.middle_column = mocker.Mock()
348349
view.set_footer_text = mocker.Mock()
349350
view.controller.is_in_editor_mode = lambda: False
@@ -367,6 +368,7 @@ def test_keypress_OPEN_DRAFT(self, view, mocker, draft, key, widget_size):
367368
emails=draft["to"], recipient_user_ids=[1, 2]
368369
)
369370

371+
assert view.body.focus_col == 1
370372
assert view.write_box.msg_write_box.edit_text == draft["content"]
371373
assert view.write_box.msg_write_box.edit_pos == len(draft["content"])
372374
view.middle_column.set_focus.assert_called_once_with("footer")

zulipterminal/ui.py

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def keypress(self, size: Tuple[int, int], key: str) -> Optional[str]:
262262
content = saved_draft["content"]
263263
self.write_box.msg_write_box.edit_text = content
264264
self.write_box.msg_write_box.edit_pos = len(content)
265+
self.body.focus_col = 1
265266
self.middle_column.set_focus("footer")
266267
else:
267268
self.set_footer_text("No draft message was saved in this session.", 3)

0 commit comments

Comments
 (0)