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

Update comment about scroll into view with hash #1484

Merged
merged 2 commits into from
Nov 30, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2021-XX-XX

- [change] Update comment about how scrollIntoView works with links using hash.
[#1484](https://github.com/sharetribe/ftw-daily/pull/1484)
- [fix] Account pages: mobile tab navigation should only scroll horizontally
[#1481](https://github.com/sharetribe/ftw-daily/pull/1481)
- [fix] Temporarily disallow Node v17, since it causes issues with dependencies.
Expand Down
17 changes: 8 additions & 9 deletions src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ const setPageScrollPosition = location => {
} else {
const el = document.querySelector(location.hash);
if (el) {
// Found element with the given fragment identifier, scrolling
// to that element.
// Found element from the current page with the given fragment identifier,
// scrolling to that element.
//
// NOTE: This isn't foolproof. It works when navigating within
// the application between pages and within a single page. It
// also works with the initial page load. However, it doesn't
// seem work work properly when refreshing the page, at least
// not in Chrome.
//
// TODO: investigate why the scrolling fails on refresh
// NOTE: This only works on in-app navigation within the same page.
// If smooth scrolling is needed between different pages, one needs to wait
// 1. loadData fetch and
// 2. code-chunk fetch
// before making el.scrollIntoView call.

el.scrollIntoView({
block: 'start',
behavior: 'smooth',
Expand Down