Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Disable cycling while editing a PM #1280

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,10 @@ def test_keypress_CYCLE_COMPOSE_FOCUS(
else:
write_box.stream_box_view(stream_id)
else:
write_box.private_box_view()
if not message_being_edited:
write_box.private_box_view()
else:
write_box.private_box_edit_view()
size = widget_size(write_box)

def focus_val(x: str) -> int:
Expand Down
27 changes: 17 additions & 10 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,22 +896,29 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
else:
header.focus_col = self.FOCUS_HEADER_BOX_STREAM
else:
all_valid = self._tidy_valid_recipients_and_notify_invalid_ones(
self.to_write_box
)
if not all_valid:
return key
# We extract recipients' user_ids and emails only once we know
# that all the recipients are valid, to avoid including any
# invalid ones.
self.update_recipients(self.to_write_box)
if self.msg_edit_state is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this commit, the previous commit - using the new edit DM box, with different widgets - results in a crash when cycling with Tab, since it tries to validate the text and it has a different widget structure.

Since this and the next commit affect the Tab behavior only, while the earlier commits handle the editable nature of the to-box and splitting out the typing notifications, I'd suggest moving these commits to the front of the PR - these are independent groups of changes that don't have to be done in a specific order. That will make the Tab fixes come in first, followed by fixing the clickable To box, and changing the notifications behavior.

all_valid = self._tidy_valid_recipients_and_notify_invalid_ones(
self.to_write_box
)
if not all_valid:
return key
# We extract recipients' user_ids and emails only once we know
# that all the recipients are valid, to avoid including any
# invalid ones.
self.update_recipients(self.to_write_box)

if not self.msg_body_edit_enabled:
return key
if self.focus_position == self.FOCUS_CONTAINER_HEADER:
self.focus_position = self.FOCUS_CONTAINER_MESSAGE
else:
self.focus_position = self.FOCUS_CONTAINER_HEADER
if self.compose_box_status == "open_with_stream":
self.focus_position = self.FOCUS_CONTAINER_HEADER
if (
self.compose_box_status == "open_with_private"
and self.msg_edit_state is None
):
self.focus_position = self.FOCUS_CONTAINER_HEADER
if self.compose_box_status == "open_with_stream":
if self.msg_edit_state is not None:
header.focus_col = self.FOCUS_HEADER_BOX_TOPIC
Expand Down