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

feat: add hash to reply in article detail page #592

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ydcjeff
Copy link
Contributor

@ydcjeff ydcjeff commented Dec 21, 2024

fix #348

This PR adds a hash symbol after each reply summary, scroll into view on click or on page load.

Comment on lines +46 to +50
useEffect(() => {
if (anchorRef.current.hash === location.hash) {
anchorRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer scroll-behavior CSS than imperative JS scrolling. I think it's OK to apply scroll-behavior globally

ref={anchorRef}
className={classes.hash}
href={`#${articleReply.replyId}`}
onClick={e => e.target.scrollIntoView({ behavior: 'smooth' })}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrollIntoView is probably not needed if we define a global scroll-behavior in CSS.

However, it would be nice if clicking # copies the URL + href into clipboard. We are already using copy-to-clipboard package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hash to new reply section & each reply in article detail page
2 participants