forked from mystiq/hydrogen-web
Merge pull request #541 from vector-im/bwindels/fix-540
scroll room list to top when entering query first
This commit is contained in:
commit
255e479d47
3 changed files with 27 additions and 14 deletions
|
@ -127,11 +127,14 @@ export class LeftPanelViewModel extends ViewModel {
|
||||||
query = query.trim();
|
query = query.trim();
|
||||||
if (query.length === 0) {
|
if (query.length === 0) {
|
||||||
this.clearFilter();
|
this.clearFilter();
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
const startFiltering = !this._tileViewModelsFilterMap.hasApply();
|
||||||
const filter = new RoomFilter(query);
|
const filter = new RoomFilter(query);
|
||||||
this._tileViewModelsFilterMap.setApply((roomId, vm) => {
|
this._tileViewModelsFilterMap.setApply((roomId, vm) => {
|
||||||
vm.hidden = !filter.matches(vm);
|
vm.hidden = !filter.matches(vm);
|
||||||
});
|
});
|
||||||
|
return startFiltering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ export class ApplyMap extends BaseObservableMap {
|
||||||
this._subscription = null;
|
this._subscription = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasApply() {
|
||||||
|
return !!this._apply;
|
||||||
|
}
|
||||||
|
|
||||||
setApply(apply) {
|
setApply(apply) {
|
||||||
this._apply = apply;
|
this._apply = apply;
|
||||||
if (apply) {
|
if (apply) {
|
||||||
|
|
|
@ -58,6 +58,19 @@ export class LeftPanelView extends TemplateView {
|
||||||
vm.i18n`Show single room` :
|
vm.i18n`Show single room` :
|
||||||
vm.i18n`Enable grid layout`;
|
vm.i18n`Enable grid layout`;
|
||||||
};
|
};
|
||||||
|
const roomList = t.view(new ListView(
|
||||||
|
{
|
||||||
|
className: "RoomList",
|
||||||
|
list: vm.tileViewModels,
|
||||||
|
},
|
||||||
|
tileVM => {
|
||||||
|
if (tileVM.kind === "invite") {
|
||||||
|
return new InviteTileView(tileVM);
|
||||||
|
} else {
|
||||||
|
return new RoomTileView(tileVM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
const utilitiesRow = t.div({className: "utilities"}, [
|
const utilitiesRow = t.div({className: "utilities"}, [
|
||||||
t.a({className: "button-utility close-session", href: vm.closeUrl, "aria-label": vm.i18n`Back to account list`, title: vm.i18n`Back to account list`}),
|
t.a({className: "button-utility close-session", href: vm.closeUrl, "aria-label": vm.i18n`Back to account list`, title: vm.i18n`Back to account list`}),
|
||||||
t.view(new FilterField({
|
t.view(new FilterField({
|
||||||
|
@ -65,7 +78,12 @@ export class LeftPanelView extends TemplateView {
|
||||||
label: vm.i18n`Filter rooms…`,
|
label: vm.i18n`Filter rooms…`,
|
||||||
name: "room-filter",
|
name: "room-filter",
|
||||||
autocomplete: true,
|
autocomplete: true,
|
||||||
set: query => vm.setFilter(query),
|
set: query => {
|
||||||
|
// scroll up if we just started filtering
|
||||||
|
if (vm.setFilter(query)) {
|
||||||
|
roomList.scrollTop = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
clear: () => vm.clearFilter()
|
clear: () => vm.clearFilter()
|
||||||
})),
|
})),
|
||||||
t.button({
|
t.button({
|
||||||
|
@ -83,19 +101,7 @@ export class LeftPanelView extends TemplateView {
|
||||||
|
|
||||||
return t.div({className: "LeftPanel"}, [
|
return t.div({className: "LeftPanel"}, [
|
||||||
utilitiesRow,
|
utilitiesRow,
|
||||||
t.view(new ListView(
|
roomList
|
||||||
{
|
|
||||||
className: "RoomList",
|
|
||||||
list: vm.tileViewModels,
|
|
||||||
},
|
|
||||||
tileVM => {
|
|
||||||
if (tileVM.kind === "invite") {
|
|
||||||
return new InviteTileView(tileVM);
|
|
||||||
} else {
|
|
||||||
return new RoomTileView(tileVM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
))
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue