-
-
Notifications
You must be signed in to change notification settings - Fork 637
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: fixed links to specific category in tools section #2190
Changes from all commits
290f3f6
6a0e589
428050b
de3ce8c
51f399d
e8cc15d
1fc1864
8b53296
51eb9f2
e30ac6e
aebbb69
d08cb6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -48,6 +48,18 @@ export default function ToolDashboard() { | |||||||
}, 1000); | ||||||||
}, []); | ||||||||
|
||||||||
// useEffect to scroll particular div into view | ||||||||
useEffect(() => { | ||||||||
setTimeout(() => { | ||||||||
const path = router?.asPath | ||||||||
const id = path?.slice(path?.indexOf("#") + 1).replace("%20", " ") | ||||||||
const element = document.getElementById(id) | ||||||||
if (element) { | ||||||||
element.scrollIntoView({ behavior: 'smooth', block: "nearest", inline: "nearest" }) | ||||||||
} | ||||||||
}, 1000) | ||||||||
}, []) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Kindly add a spacing to make it more readable inside codebase (since they are 2 different sections of code). |
||||||||
|
||||||||
// useEffect function to enable the close Category dropdown Modal feature when clicked outside of the modal | ||||||||
useEffect(() => { | ||||||||
const checkIfClickOutside = (e) => { | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why there are changes in this file? |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using
id
attribute, can't we useref
here to add the behavior?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can think about this, but the "Jump to Category" dropdown already uses the "id" of each div to scroll to, so wouldn't it be better to use the same strategy for initial scrolling as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually access the DOM elements directly in react. React has it's own virtual DOM feature which enables better performance on the website. That's why I asked to use ref in this case. We used
id
just to reference the category and link it in dropdown.