Repository navigation
fix: [UI-8803] - IAM Cross browser AssignedRoles entities chips truncation #12720
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b16d0d
fix some
abailly-akamai a9c5b96
improve ellipsis pattern
abailly-akamai a4869be
cleanup
abailly-akamai 3b486ac
cleanup
abailly-akamai 37d6d37
Added changeset: IAM - Cross browser AssignedRoles entities chips truβ¦
abailly-akamai 7b09df5
Merge branch 'develop' into UIE-8803
abailly-akamai aa27011
Merge branch 'develop' into UIE-8803
abailly-akamai 20d5100
Merge branch 'develop' into UIE-8803
abailly-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Fixed | ||
| --- | ||
|
|
||
| IAM - Cross browser AssignedRoles entities chips truncation ([#12720](https://github.com/linode/manager/pull/12720)) |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -24,13 +24,15 @@ export const AssignedEntities = ({ | |
| useCalculateHiddenItems(role.entity_names!); | ||
|
|
||
| const handleResize = React.useMemo( | ||
| () => debounce(() => calculateHiddenItems(), 100), | ||
| () => debounce(() => calculateHiddenItems(), 250), | ||
| [calculateHiddenItems] | ||
| ); | ||
|
|
||
| React.useEffect(() => { | ||
| // Ensure calculateHiddenItems runs after layout stabilization on initial render | ||
| const rafId = requestAnimationFrame(() => calculateHiddenItems()); | ||
| // Double RAF for good measure - see https://stackoverflow.com/questions/44145740/how-does-double-requestanimationframe-work | ||
| const rafId = requestAnimationFrame(() => { | ||
| requestAnimationFrame(() => calculateHiddenItems()); | ||
| }); | ||
|
|
||
| window.addEventListener('resize', handleResize); | ||
|
|
||
|
|
@@ -49,14 +51,27 @@ export const AssignedEntities = ({ | |
| [role.entity_names, role.entity_ids] | ||
| ); | ||
|
|
||
| const isLastVisibleItem = React.useCallback( | ||
| (index: number) => { | ||
| return combinedEntities.length - numHiddenItems - 1 === index; | ||
| }, | ||
| [combinedEntities.length, numHiddenItems] | ||
| ); | ||
|
|
||
| const items = combinedEntities?.map( | ||
| (entity: CombinedEntity, index: number) => ( | ||
| <div | ||
| <Box | ||
| key={entity.id} | ||
| ref={(el: HTMLDivElement) => { | ||
| itemRefs.current[index] = el; | ||
| }} | ||
| style={{ display: 'inline-block', marginRight: 8 }} | ||
| sx={{ | ||
| display: 'inline', | ||
| marginRight: | ||
| numHiddenItems > 0 && isLastVisibleItem(index) | ||
| ? theme.tokens.spacing.S16 | ||
| : theme.tokens.spacing.S8, | ||
| }} | ||
| > | ||
| <Chip | ||
| data-testid="entities" | ||
|
|
@@ -76,9 +91,18 @@ export const AssignedEntities = ({ | |
| '& .MuiChip-deleteIcon': { | ||
| color: theme.tokens.alias.Content.Text.Primary.Default, | ||
| }, | ||
| position: 'relative', | ||
| '&::after': { | ||
| content: | ||
| numHiddenItems > 0 && isLastVisibleItem(index) ? '"..."' : '""', | ||
| position: 'absolute', | ||
| top: 0, | ||
| right: -16, | ||
| width: 14, | ||
| }, | ||
| }} | ||
| /> | ||
| </div> | ||
| </Box> | ||
| ) | ||
| ); | ||
|
|
||
|
|
@@ -87,19 +111,18 @@ export const AssignedEntities = ({ | |
| sx={{ | ||
| alignItems: 'center', | ||
| display: 'flex', | ||
| position: 'relative', | ||
| }} | ||
| > | ||
| <div | ||
| <Box | ||
| ref={containerRef} | ||
| style={{ | ||
| WebkitBoxOrient: 'vertical', | ||
| WebkitLineClamp: 1, | ||
| display: '-webkit-box', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These was the ultimate culprit |
||
| sx={{ | ||
| overflow: 'hidden', | ||
| height: 24, | ||
| }} | ||
| > | ||
| {items} | ||
| </div> | ||
| </Box> | ||
| {numHiddenItems > 0 && ( | ||
| <Box | ||
| sx={{ | ||
|
|
||
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.
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.
The debounce was a bit too aggressive and over-rendering the component on resize