Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save visited url on scroll on every navigation rather than on specific transition. #545

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export class ScrollController {
return window.location;
}

store() {
onEveryRouteChange() {
this.#shouldScrollToTop = this.#lastVisitedUrl.toLowerCase() !== this.location.pathname.toLowerCase();
this.#lastVisitedUrl = this.location.pathname;
}

store() {
if (this.location.hash) {
const node = this.#hashStoreNode;
const hashValue = this.#getHashValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ describe('ScrollController', () => {

it('should not scroll to top if store has recorded navigation between the same path', () => {
scrollSpy = sinon.spy(window, 'scroll');
scrollController.store();
scrollController.store();
scrollController.onEveryRouteChange();
scrollController.onEveryRouteChange();

scrollController.restore();

Expand Down
16 changes: 9 additions & 7 deletions ilc/client/TransitionManager/TransitionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,16 @@ export class TransitionManager {
};

#onRouteChange = () => {
if (this.#transitionBlockers.isEmpty()) {
this.#onPageReady();
if (!this.#transitionBlockers.isEmpty()) {
return;
}

if (!this.#transitionBlockers.isReady()) {
this.#transitionBlockers.init();
// ilcEvents.ALL_SLOTS_LOADED is dispatched only on first page load here
window.dispatchEvent(new CustomEvent(ilcEvents.ALL_SLOTS_LOADED));
}
this.#scrollController.onEveryRouteChange();
this.#onPageReady();
if (!this.#transitionBlockers.isReady()) {
this.#transitionBlockers.init();
// ilcEvents.ALL_SLOTS_LOADED is dispatched only on first page load here
window.dispatchEvent(new CustomEvent(ilcEvents.ALL_SLOTS_LOADED));
}
};
}
5 changes: 1 addition & 4 deletions registry/server/templates/services/resources/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ export abstract class Resource {
...Attributes.crossorigin,
};

constructor(
public uri: string,
params?: Params,
) {
constructor(public uri: string, params?: Params) {
this.params = params || {};
}

Expand Down
11 changes: 4 additions & 7 deletions registry/server/templates/services/templatesRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ export async function readTemplateWithAllVersions(templateName: string) {
.select()
.from<LocalizedTemplate>(tables.templatesLocalized)
.where('templateName', templateName);
template.localizedVersions = localizedTemplates.reduce(
(acc, item) => {
acc[item.locale] = { content: item.content };
return acc;
},
{} as Record<string, object>,
);
template.localizedVersions = localizedTemplates.reduce((acc, item) => {
acc[item.locale] = { content: item.content };
return acc;
}, {} as Record<string, object>);

return template;
}
Expand Down
Loading