Fix search not being cleared when clicking on a result (#9635)
* Fix test naming * Fix search not being cleared when clicking on a result * Update RoomView.tsx * Update RoomView.tsx
This commit is contained in:
parent
55d3522fcd
commit
8bd60d09dc
2 changed files with 9 additions and 6 deletions
|
@ -534,8 +534,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
const roomId = this.context.roomViewStore.getRoomId();
|
const roomId = this.context.roomViewStore.getRoomId();
|
||||||
const room = this.context.client.getRoom(roomId);
|
const room = this.context.client.getRoom(roomId);
|
||||||
|
|
||||||
// This convoluted type signature ensures we get IntelliSense *and* correct typing
|
const newState: Partial<IRoomState> = {
|
||||||
const newState: Partial<IRoomState> & Pick<IRoomState, any> = {
|
|
||||||
roomId,
|
roomId,
|
||||||
roomAlias: this.context.roomViewStore.getRoomAlias(),
|
roomAlias: this.context.roomViewStore.getRoomAlias(),
|
||||||
roomLoading: this.context.roomViewStore.isRoomLoading(),
|
roomLoading: this.context.roomViewStore.isRoomLoading(),
|
||||||
|
@ -679,11 +678,15 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
|
|
||||||
// Clear the search results when clicking a search result (which changes the
|
// Clear the search results when clicking a search result (which changes the
|
||||||
// currently scrolled to event, this.state.initialEventId).
|
// currently scrolled to event, this.state.initialEventId).
|
||||||
if (this.state.initialEventId !== newState.initialEventId) {
|
if (this.state.timelineRenderingType === TimelineRenderingType.Search &&
|
||||||
newState.searchResults = null;
|
this.state.initialEventId !== newState.initialEventId
|
||||||
|
) {
|
||||||
|
newState.timelineRenderingType = TimelineRenderingType.Room;
|
||||||
|
this.state.search?.abortController?.abort();
|
||||||
|
newState.search = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState(newState as IRoomState);
|
||||||
// At this point, newState.roomId could be null (e.g. the alias might not
|
// At this point, newState.roomId could be null (e.g. the alias might not
|
||||||
// have been resolved yet) so anything called here must handle this case.
|
// have been resolved yet) so anything called here must handle this case.
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ jest.mock("../../../src/Searching", () => ({
|
||||||
searchPagination: jest.fn(),
|
searchPagination: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("<SearchRoomView/>", () => {
|
describe("<RoomSearchView/>", () => {
|
||||||
const eventMapper = (obj: Partial<IEvent>) => new MatrixEvent(obj);
|
const eventMapper = (obj: Partial<IEvent>) => new MatrixEvent(obj);
|
||||||
const resizeNotifier = new ResizeNotifier();
|
const resizeNotifier = new ResizeNotifier();
|
||||||
let client: MatrixClient;
|
let client: MatrixClient;
|
Loading…
Add table
Add a link
Reference in a new issue