Skip to content

Commit 05ff31a

Browse files
committed
bugfix: ui: Focus on content_area when draft is opened from side-panels.
This commit fixes a bug that caused the focus to not move to the content area if the draft was opened from the side-panels. This is minor bugfix that should set the focus to the message_column before setting it to the footer(i.e. content_area). We also added tests for OPEN_DRAFT in the previous commit and amend it in this commit to allow it to pass for the added bugfix. Tests amended.
1 parent f398603 commit 05ff31a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

tests/ui/test_ui.py

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)