-
Notifications
You must be signed in to change notification settings - Fork 66
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
LG-4830: add DrawerTabs component #2720
Conversation
|
Name | Type |
---|---|
@leafygreen-ui/drawer | Major |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
6380b80
to
afe67e6
Compare
55339e8
to
50b5b59
Compare
afe67e6
to
821c407
Compare
Size Change: +2.39 kB (+0.17%) Total Size: 1.41 MB
ℹ️ View Unchanged
|
821c407
to
6039866
Compare
setHasShadowTop(scrollContainerEl.scrollTop > 0); | ||
}; | ||
|
||
scrollContainerEl.addEventListener('scroll', handleScroll); |
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.
nit: while working on table, I found that IntersectionObserver was helpful in avoiding frequent scroll event handling. Maybe it could be beneficial here?
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.
thanks for the suggestion! I was able to implement something similar here and cut out the additions to the tabs package :)
const handleScroll = () => { | ||
setHasShadowTop(scrollContainerEl.scrollTop > 0); | ||
}; |
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.
Nit 1: Since scrollContainerRef
is accessible outside of the useEffect
callback, this function doesn't need to be recreated on every call and can be moved to the outer scope and only initialized once on mount using useCallback
. It's so small I'm not worried about it so definitely feel free to leave as is if you think it improves readability.
Nit 2: (I think @shaneeza's suggestion would solve this in a better way, but will still leave this in case you don't go in that direction) Currently this function is going to fire quite a bit on scroll. It's sometimes advisable to debounce scroll handlers to minimize this a bit.
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.
updated to using useInView
which uses the intersection observer under the hood
829b2b2
to
35a239c
Compare
35a239c
to
39141ff
Compare
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.
Are you adding test utils for tabs?
The |
✍️ Proposed changes
tabListContainerRef
andtabPanelsContainerRef
props toTabs
componentDrawerTabs
component🎟 Jira ticket: LG-4830
✅ Checklist
For bug fixes, new features & breaking changes
pnpm changeset
and documented my changes🧪 How to test changes
Drawer/Scroll
storyDrawer/WithTabs
story