-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: always inline toolbar for listbox popover
- Loading branch information
1 parent
3442169
commit 5620640
Showing
5 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
apis/nucleus/src/components/listbox/interactions/listbox-get-action-props.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
apis/nucleus/src/components/listbox/interactions/listbox-show-toolbar-detached.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
/* eslint-disable no-nested-ternary */ | ||
export default function showToolbarDetached({ containerRef, titleRef, iconsWidth }) { | ||
const containerWidth = containerRef?.current?.clientWidth ?? 0; | ||
const padding = 16; | ||
const contentWidth = (titleRef?.current?.clientWidth ?? 0) + iconsWidth + padding; | ||
const actionToolbarWidth = 128; | ||
const notSufficientSpace = containerWidth < contentWidth + actionToolbarWidth; | ||
const isTruncated = titleRef?.current?.scrollWidth > titleRef?.current?.offsetWidth; | ||
const isDetached = !!(notSufficientSpace | isTruncated); | ||
const reasonDetached = isDetached ? (notSufficientSpace ? 'noSpace' : 'truncated') : ''; | ||
|
||
return !!(notSufficientSpace | isTruncated); | ||
return { isDetached, reasonDetached }; | ||
} |