Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Mark room as read when escape is pressed #4271

Merged
merged 3 commits into from
Apr 30, 2020

Conversation

aaronraimist
Copy link
Contributor

Signed-off-by: Aaron Raimist <aaron@raim.ist>
@t3chguy
Copy link
Member

t3chguy commented Mar 25, 2020

Can this get matching documentation in the keyboard shortcuts dialog?

@t3chguy t3chguy self-requested a review March 25, 2020 09:51
@aaronraimist
Copy link
Contributor Author

I guess this would fit best in the Navigation section? There isn't really a section for the room view.

There is already an Esc shortcut in that section. Do you want me to add another one or do you want me to add it to the description of the existing shortcut?

@t3chguy
Copy link
Member

t3chguy commented Mar 26, 2020

For now I guess just add it to the description of the existing shortcut, also do ensure that this doesn't wrongly trigger when one of those shortcuts is caught. E.g when closing a context menu I don't want my timeline to reset to bottom.

Once we have a more complete inventory of shortcuts the categorization may change up.

Thanks

@aaronraimist
Copy link
Contributor Author

Yeah it does seem to trigger multiple things. I don't know how to prevent that.

@t3chguy
Copy link
Member

t3chguy commented Mar 29, 2020

So the issue here is RoomView listens on a native event handler not a React one so it'll trigger regardless unless you tie up every other Key.ESCAPE path with ev.nativeEvent.stopImmediatePropagation(); which seems ugly. I would definitely not register any "ambiguous" shortcuts (unlike e.g Cmd+E) in RoomView's onKeyDown because of this.

Something like this seems to work, if you could also put a comment in RoomView's onKeyDown to point out its a global document native handler that'd be swell to avoid this issue in future.

Index: src/components/structures/RoomView.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/components/structures/RoomView.js	(revision 76104edeca3b8ba37d4a24903fa1e0193dad56c2)
+++ src/components/structures/RoomView.js	(date 1585517162034)
@@ -560,12 +560,6 @@
                     handled = true;
                 }
                 break;
-
-            case Key.ESCAPE:
-                this._messagePanel.forgetReadMarker();
-                this.jumpToLiveTimeline();
-                handled = true;
-                break;
         }
 
         if (handled) {
Index: src/components/structures/LoggedInView.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/components/structures/LoggedInView.js	(revision 76104edeca3b8ba37d4a24903fa1e0193dad56c2)
+++ src/components/structures/LoggedInView.js	(date 1585517123393)
@@ -406,6 +406,16 @@
                     });
                     handled = true;
                 }
+                break;
+
+            case Key.ESCAPE:
+                if (!hasModifier && this._roomView.current) {
+                    this._roomView.current._messagePanel.forgetReadMarker();
+                    this._roomView.current.jumpToLiveTimeline();
+                    handled = true;
+                }
+                break;
         }
 
         if (handled) {

@t3chguy
Copy link
Member

t3chguy commented Mar 29, 2020

Equally you could create an onKeyDown in RoomView which is handled by React which would probably be cleaner in terms of keeping related code together 🤷‍♂

@t3chguy
Copy link
Member

t3chguy commented Apr 7, 2020

Hey @aaronraimist are you still interested in taking this on?

@aaronraimist
Copy link
Contributor Author

Yes but I'd like to do it the second way and I don't honestly know how to do that. Feel free to finish this up if you like.

@t3chguy
Copy link
Member

t3chguy commented Apr 8, 2020

Any reason this makes Esc jump to bottom too, this seems unlike Discord and Slack at least.

@aaronraimist
Copy link
Contributor Author

Mainly because element-hq/element-web#12537 asked for it. Discord does scroll to the bottom when pressing Esc.

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy t3chguy requested review from a team and removed request for t3chguy April 14, 2020 14:25
@t3chguy
Copy link
Member

t3chguy commented Apr 14, 2020

Pushed my change up to your branch, now back up for review, but product/design/someone in control needs to decide if we want it to jump to bottom too or not, also still needs documenting in the Keyboard Shortcuts dialog.

@t3chguy t3chguy removed the request for review from a team April 14, 2020 14:26
@nadonomy
Copy link
Contributor

Does this PR also scroll down the timeline as described in element-hq/element-web#12537?

@t3chguy
Copy link
Member

t3chguy commented Apr 17, 2020

Currently, yes. Like Discord, unlike Slack. Made the desired behaviour a product/design decision.

@valynor
Copy link

valynor commented Apr 20, 2020

Just heard about this upcoming feature, I would like to suggest:
first ESC press marks read, second ESC press scrolls to bottom

Best of both worlds. :-)

@nadonomy
Copy link
Contributor

This LGTM.

@valynor I'd suggest filing a new issue for your suggestion as we'll want to merge this PR as is to avoid bit rot.

@turt2live turt2live requested a review from a team April 29, 2020 00:48
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this!

@turt2live turt2live merged commit 7b775a8 into matrix-org:develop Apr 30, 2020
@t3chguy
Copy link
Member

t3chguy commented Apr 30, 2020

also still needs documenting in the Keyboard Shortcuts dialog.

:((

@turt2live
Copy link
Member

That should have been a request changes then :(

@aaronraimist aaronraimist deleted the esc-mark-as-read branch April 1, 2021 04:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing escape should mark messages as read and jump to most recent
5 participants