Skip to content

Commit

Permalink
fix(pwa-element): scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Apr 19, 2023
1 parent bf0ce66 commit 136dbd0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ui/pwa-helper/src/pwa-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,23 @@ export class AlwatrPwaElement extends RouterMixin(SignalMixin(UnresolvedMixin(Al

override connectedCallback(): void {
super.connectedCallback();

if (!localeContextConsumer.getValue()) {
setLocale();
}
this._addSignalListeners(
commandHandler.define<{smooth?: boolean}, undefined>(scrollToTopCommand.id, (option): undefined => {

this._addSignalListeners(commandHandler.define<{smooth?: boolean}, undefined>(
scrollToTopCommand.id,
async (option): Promise<undefined> => {
await untilNextFrame();
this.renderRoot.querySelector('.scroll-area')?.scrollTo({
top: 0,
left: 0,
behavior: option.smooth ? 'smooth' : 'auto',
});
return;
}),
);
},
));
}

protected _routesConfig: RoutesConfig = {
Expand All @@ -91,7 +95,7 @@ export class AlwatrPwaElement extends RouterMixin(SignalMixin(UnresolvedMixin(Al

protected override _routeContextUpdated(routeContext: RouteContext): void {
super._routeContextUpdated(routeContext);
// scrollToTopCommand.request({smooth: true});
scrollToTopCommand.request({smooth: true});
}

protected override async scheduleUpdate(): Promise<void> {
Expand Down

0 comments on commit 136dbd0

Please sign in to comment.