Skip to content

Commit 27e992f

Browse files
committed
#282 Covid.view.MainContainerController: onHashChange() => delay to apply the new country selection when switching cards, button changeRoute adjustments
1 parent af09809 commit 27e992f

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

apps/covid/view/MainContainerController.mjs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ class MainContainerController extends ComponentController {
286286
activeIndex = me.getTabIndex(value),
287287
tabContainer = me.getReference('tab-container'),
288288
activeView = me.getView(activeIndex),
289+
switchView = tabContainer.activeIndex !== activeIndex,
289290
id;
290291

291292
// console.log('onHashChange', value);
@@ -300,16 +301,18 @@ class MainContainerController extends ComponentController {
300301
}
301302

302303
if (value.country) {
303-
if (activeView.ntype === 'table-container') {
304-
id = activeView.selectionModel.getRowId(activeView.store.indexOf(value.country));
305-
activeView.selectionModel.select(id);
306-
307-
Neo.main.DomAccess.scrollIntoView({
308-
id: id
309-
});
310-
} else {
311-
activeView.selectionModel.select(value.country);
312-
}
304+
setTimeout(() => {
305+
if (activeView.ntype === 'table-container') {
306+
id = activeView.selectionModel.getRowId(activeView.store.indexOf(value.country));
307+
activeView.selectionModel.select(id);
308+
309+
Neo.main.DomAccess.scrollIntoView({
310+
id: id
311+
});
312+
} else {
313+
activeView.selectionModel.select(value.country);
314+
}
315+
}, switchView ? 100 : 0);
313316
}
314317
}
315318

src/Main.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ class Main extends core.Base {
128128
let hashObj = DomEvents.parseHash(window.location.hash.substr(1)),
129129
hashArr = [];
130130

131+
if (typeof data === 'string') {
132+
data = DomEvents.parseHash(data);
133+
}
134+
131135
Object.assign(hashObj, data);
132136

133137
Object.entries(hashObj).forEach(([key, value]) => {

src/component/Button.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,15 @@ class Button extends Component {
275275
* @private
276276
*/
277277
changeRoute() {
278-
Neo.Main[this.editRoute ? 'editRoute' : 'setRoute']({
279-
value: this.route
280-
});
278+
const me = this;
279+
280+
if (me.editRoute) {
281+
Neo.Main.editRoute(this.route);
282+
} else {
283+
Neo.Main.setRoute({
284+
value: me.route
285+
});
286+
}
281287
}
282288
}
283289

0 commit comments

Comments
 (0)