Skip to content

Ignore mouse click if compose box is open. #720

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

Closed

Conversation

kaustubh-nair
Copy link
Member

@kaustubh-nair kaustubh-nair commented Jul 16, 2020

Clicking on messages/user names when the compose box is open causes the
current message to be lost. This commits ignores the mouse click to
prevent the typed data to be lost, though better handling can be done
when the drafts feature is implemented.

Also, stored controller as an attribute for UsersView. Tests amended for
this.

Test added for mouse click event.

Fixes #652.

@zulipbot zulipbot added size: M [Automatic label added by zulipbot] bug Something isn't working high priority should be done as soon as possible labels Jul 16, 2020
@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch 2 times, most recently from 8e2832a to b7f9b87 Compare July 16, 2020 17:26
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Jul 16, 2020
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@kaustubh-nair This avoids the crash from compose->compose, at least from manual testing 👍

As you noted in the chat however, similar issues apply for being in a (any?) search box and entering compose (ie. search -> compose), which it would be good to address at the same time, if possible?

I understand the thought of being general in the code, but for the purposes of the original solution, wrapping the functionality slightly differently in the controller may simplify it for the calling code, as per the inline comment. For the more general case I could understand the approach you took initially, but can we achieve the same result with only is_in_editor_mode()?

@preetmishra mentioned similar issues between search boxes too, at least with regard to focus, though not crashing, which we might resolve in a similar way?

Some of these are added extras for consistency and avoiding strange behavior, but focusing on needing GO_BACK to leave search text entry or message composition/editing feels like a good baseline? It might be worth analyzing use of that key and clarifying the token name and description, based on the usage, rather than having simply 'go back'. We could work on having compose open while navigating, but that feels like a separate feature at this stage?

Comment on lines 838 to 839
write_box = controller.view.middle_column.contents['footer'][0]
if controller.is_in_editor_mode_with(write_box):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is common to both cases, which suggests this could be in a common controller.is_composing_message_now() or similar?

@kaustubh-nair
Copy link
Member Author

@neiljp making a method in the controller sounds like a good idea.

I needed is_in_editor_mode_with() because we might require different behavior depending on which editor is active ( for example search boxes ) but if simply requiring a GO_BACK is enough for now then we think about this in follow-ups.

@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch from b7f9b87 to 841007d Compare July 17, 2020 09:40
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Jul 17, 2020
@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch from 841007d to 652653d Compare July 17, 2020 09:42
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Jul 17, 2020
@kaustubh-nair
Copy link
Member Author

@neiljp Thanks for the review, PR updated 👍

@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch from 652653d to b917ec0 Compare July 17, 2020 17:04
@kaustubh-nair kaustubh-nair changed the title ui: Ignore mouse click if compose box is open. Ignore mouse click if compose box is open. Jul 17, 2020
@kaustubh-nair kaustubh-nair added the PR needs review PR requires feedback to proceed label Jul 17, 2020
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@kaustubh-nair This looks good 👍 I'm happy to merge this with a few minor changes.

Did this previously give data-loss with no crash, but gives a crash after my refactoring to add the assert? The commit message suggests the former, whereas the current code reflects the latter? In both cases we lose data, but 'causes message to be lost' doesn't really reflect the code at this point, so let's have the commit text reflect the current behavior - though we can of course mention how the bug changed with the refactoring if you like.

Other minor points:

  • You could indicate that this is a bugfix: area, which we have used in the past as an additional area in the commit titles. We could update the developer docs to reflect the commit text style further, since we don't mention that
  • In future we could maybe improve the nearby tests, given the left/right click notes, but that may be covered in an existing older PR by @preetmishra in any case, or at least is very similar?

While not overly significant since it's not a major issue and involves mouse usage, the focus still changes even with clicks - that's noticeable given the cursor stops blinking in the box we're typing in. That applies to searching too, so could be another spinoff issue/PR, a little like #724?

@@ -2248,21 +2267,30 @@ def test_footlinks_view(self, message_fixture, message_links,
assert footlinks is None
assert not hasattr(footlinks, 'original_widget')

@pytest.mark.parametrize('compose_box_open', [True, False])
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: this would be more transparent as in_editor_mode or similar?

Consider using ids since eg. True isn't that obvious in the test summary. Maybe a local fixture given it's used twice?

@neiljp neiljp added this to the 0.5.2 milestone Jul 19, 2020
@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch from b917ec0 to 562e638 Compare July 19, 2020 06:34
Clicking on messages when the compose box is open causes ZT to crash,
and having it open when clicking on user names causes the current message
to be lost. This commits ignores the mouse click to prevent this
from happening, though better handling can be done when the drafts
feature is implemented.

Also, stored controller as an attribute for UsersView. Tests amended for
this.

Test added for mouse click event.

Fixes zulip#652.
@kaustubh-nair kaustubh-nair force-pushed the mouse-click-compose-box branch from 562e638 to acae7a0 Compare July 19, 2020 06:47
@kaustubh-nair
Copy link
Member Author

kaustubh-nair commented Jul 19, 2020

@neiljp, thanks for the review, updated PR!
Re. Opened an issue for dealing with the cursor. #728

@neiljp
Copy link
Collaborator

neiljp commented Jul 19, 2020

@kaustubh-nair Thanks for the fix! Just manually merged 🎉 (you had a different file in your commit title than in the commit)

@neiljp neiljp closed this Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority should be done as soon as possible PR needs review PR requires feedback to proceed size: L [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking on a compose-triggering location cancels current compose
3 participants