-
Notifications
You must be signed in to change notification settings - Fork 162
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: Make Breadcrumb group component responsive #2671
Conversation
7e272da
to
50c1f00
Compare
50c1f00
to
b9630d1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2671 +/- ##
==========================================
+ Coverage 95.79% 95.92% +0.12%
==========================================
Files 744 745 +1
Lines 20569 20658 +89
Branches 6964 6663 -301
==========================================
+ Hits 19705 19817 +112
- Misses 808 833 +25
+ Partials 56 8 -48 ☔ View full report in Codecov by Sentry. |
setItemsWidths(newItemsWidths); | ||
} | ||
} | ||
}, [itemsWidths, items, navWidth]); |
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.
You have a double render loop here. After calling setItemsWidth
, this effect is called second time, because it tracks itemsWidths
value which got just changed.
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.
Suggested solution
setItemsWidths(oldWidths => {
if (
!areArrayEqual(newItemsWidths.ghost, oldWidths.ghost) ||
!areArrayEqual(newItemsWidths.real, oldWidths.real)
) {
return newItemsWidths;
} else {
return oldWidths
}
})
@@ -106,10 +126,45 @@ export function BreadcrumbGroupImplementation<T extends BreadcrumbGroupProps.Ite | |||
checkSafeUrl('BreadcrumbGroup', item.href); | |||
} | |||
const baseProps = getBaseProps(props); | |||
const isMobile = useMobile(); | |||
const [navWidth, navRef] = useContainerQuery<number>(rect => rect.contentBoxWidth); |
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.
This should be rect.borderBoxWidth
to incorporate inner paddings, if there are any
Description
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
. N/ACONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.