From 04b521c48b51e20178ec9b0e581b596ebc077bd8 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 4 Apr 2019 17:03:06 -0600 Subject: [PATCH] Scroll breadcrumbs to the left when they change Fixes https://github.com/vector-im/riot-web/issues/9355 --- src/components/structures/IndicatorScrollbar.js | 7 +++++++ src/components/views/rooms/RoomBreadcrumbs.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/components/structures/IndicatorScrollbar.js b/src/components/structures/IndicatorScrollbar.js index 263a0a22ba..03e1f8db04 100644 --- a/src/components/structures/IndicatorScrollbar.js +++ b/src/components/structures/IndicatorScrollbar.js @@ -40,6 +40,13 @@ export default class IndicatorScrollbar extends React.Component { }; } + moveToOrigin() { + if (!this._scrollElement) return; + + this._scrollElement.scrollLeft = 0; + this._scrollElement.scrollTop = 0; + } + _collectScroller(scroller) { if (scroller && !this._scrollElement) { this._scrollElement = scroller; diff --git a/src/components/views/rooms/RoomBreadcrumbs.js b/src/components/views/rooms/RoomBreadcrumbs.js index 314b2912cd..c76b174d4a 100644 --- a/src/components/views/rooms/RoomBreadcrumbs.js +++ b/src/components/views/rooms/RoomBreadcrumbs.js @@ -173,6 +173,10 @@ export default class RoomBreadcrumbs extends React.Component { rooms.splice(MAX_ROOMS, rooms.length - MAX_ROOMS); } this.setState({rooms}); + + if (this.refs.scroller) { + this.refs.scroller.moveToOrigin(); + } } _viewRoom(room) {