Skip to content

Commit

Permalink
style: cancel old highlight animations
Browse files Browse the repository at this point in the history
I.e. when we highlight a new message as a result of `jumpToMessage`,
remove the animation on the previously highlighted message
(or messages).

This is particularly useful for the Ctrl + Up shortcut
which is to choose the message to reply to.
  • Loading branch information
WofWca committed Oct 10, 2024
1 parent bdca272 commit 6f00432
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- losing scrolling "momentum" while scrolling the messages list fast #4122
- fix crash when you chose Settings from a context menu on account you haven't selected #4190
- fix All Media not opening from a context menu on account you haven't selected #4191
- cancel old message highlight animations when a new message is highlighted

<a id="1_46_8"></a>

Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/components/message/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ export default function MessageList({ accountId, chat, refComposer }: Props) {
domElement.tagName === 'LI' ? domElement : domElement.parentElement
if (highlightableElement !== null) {
setTimeout(() => {
// Stop the animation on the previously highlighted message.
highlightableElement.parentElement
?.querySelectorAll(':scope > .highlight')
.forEach(el => el.classList.remove('highlight'))

// Retrigger animation
highlightableElement.classList.add('highlight')
highlightableElement.style.animation = 'none'
Expand Down

0 comments on commit 6f00432

Please sign in to comment.