-
Notifications
You must be signed in to change notification settings - Fork 153
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(HorizontalScroll): adjust arrows visibility when component is ove… #4533
Conversation
Storybook staging is available at https://kiwicom-orbit-sarka-horizontal-scroll-arrow-fix.surge.sh |
Size Change: -26 B (-0.01%) Total Size: 459 kB
ℹ️ View Unchanged
|
Deploying orbit with Cloudflare Pages
|
a353957
to
aecefeb
Compare
I tested changes in editor on docs page and also in Playground:
|
@@ -20,6 +19,35 @@ const getSnap = (scrollSnap: ScrollSnap) => { | |||
return scrollSnap; | |||
}; | |||
|
|||
const getTriggerOffset = (spacing: string) => { |
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.
Tbh, I'm not sure if it's the best approach (probably not (?)), however, I needed to get the pixel value of set spacing and use this value as an integer for TRIGGER_OFFSET
const. This value is used for computations in handleScroll
functions, which is crucial for setting the visibility of arrow buttons.
I was (am) considering having this function in a specific file - the goal is to have it reusable in the future, but currently, it's used only within this file (and I don't know if it will be needed anywhere else one day), so I added it here.
I have tested with the code provided on the original request and noticed no change. Can you please confirm? |
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.
I wonder if the code provided on the bug report is correct. Shouldn't the HorizontalScroll be inside TabList
? 🤔
@@ -76,6 +104,8 @@ const HorizontalScroll = React.forwardRef<HTMLDivElement, Props>( | |||
const theme = useTheme(); | |||
const scrollEl = scrollWrapperRef.current; | |||
|
|||
const TRIGGER_OFFSET = getTriggerOffset(spacing); |
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.
All uppercase constants should be the same value every time, not calculated in runtime
@@ -20,6 +19,35 @@ const getSnap = (scrollSnap: ScrollSnap) => { | |||
return scrollSnap; | |||
}; | |||
|
|||
const getTriggerOffset = (spacing: string) => { |
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.
fed7e3c
to
bb5e2da
Compare
bb5e2da
to
119d8e2
Compare
@@ -11,8 +11,6 @@ import ChevronBackward from "../icons/ChevronBackward"; | |||
import ChevronForward from "../icons/ChevronForward"; | |||
import type { Props, ScrollSnap } from "./types"; | |||
|
|||
const TRIGGER_OFFSET = 20; |
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.
I'm still curious why we added this in the first place and can't see any new glitch by removing it… So I guess it will have to work for now
…rflowing
This Pull Request meets the following criteria:
For new components:
d.ts
files and are exported inindex.d.ts
Closes https://kiwicom.atlassian.net/browse/FEPLT-1749