[TBCCT-438/444] polishes useScrollSpy behaviour #490
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes updates to the
useScrollSpy
hook and its usage in components, along with a minor import reordering. The most important changes focus on improving the logic for handling intersecting elements in theuseScrollSpy
hook and updating therootMargin
configuration for specific components.Updates to
useScrollSpy
hook:IntersectionObserver
callback to filter and handle only intersecting entries, ensuring the first intersected element is processed. If no elements are intersecting, thesetCurrentStep
function is called withnull
. This improves clarity and robustness when managing scroll-based interactions. (client/src/hooks/use-scroll-spy.ts
, client/src/hooks/use-scroll-spy.tsL41-L46)Component-specific adjustments:
rootMargin
property from theProfile
component'suseScrollSpy
configuration, simplifying its scroll behavior. (client/src/containers/profile/index.tsx
, client/src/containers/profile/index.tsxL84)rootMargin
property to theCustomProjectForm
component'suseScrollSpy
configuration, fine-tuning its scroll behavior for better user experience. (client/src/containers/projects/form/index.tsx
, client/src/containers/projects/form/index.tsxR48)Code style improvement:
use-scroll-spy.ts
to follow a consistent and logical structure. (client/src/hooks/use-scroll-spy.ts
, client/src/hooks/use-scroll-spy.tsL1-R1)