@@ -534,8 +534,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
534
534
const roomId = this . context . roomViewStore . getRoomId ( ) ;
535
535
const room = this . context . client . getRoom ( roomId ) ;
536
536
537
- // This convoluted type signature ensures we get IntelliSense *and* correct typing
538
- const newState : Partial < IRoomState > & Pick < IRoomState , any > = {
537
+ const newState : Partial < IRoomState > = {
539
538
roomId,
540
539
roomAlias : this . context . roomViewStore . getRoomAlias ( ) ,
541
540
roomLoading : this . context . roomViewStore . isRoomLoading ( ) ,
@@ -679,11 +678,15 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
679
678
680
679
// Clear the search results when clicking a search result (which changes the
681
680
// currently scrolled to event, this.state.initialEventId).
682
- if ( this . state . initialEventId !== newState . initialEventId ) {
683
- newState . searchResults = null ;
681
+ if ( this . state . timelineRenderingType === TimelineRenderingType . Search &&
682
+ this . state . initialEventId !== newState . initialEventId
683
+ ) {
684
+ newState . timelineRenderingType = TimelineRenderingType . Room ;
685
+ this . state . search ?. abortController ?. abort ( ) ;
686
+ newState . search = undefined ;
684
687
}
685
688
686
- this . setState ( newState ) ;
689
+ this . setState ( newState as IRoomState ) ;
687
690
// At this point, newState.roomId could be null (e.g. the alias might not
688
691
// have been resolved yet) so anything called here must handle this case.
689
692
0 commit comments