diff --git a/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx b/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx index f5231c2dfd058..b86624ebd1008 100644 --- a/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx +++ b/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx @@ -38,8 +38,8 @@ export const MiddleTruncate = ({text, showTitle = true}: Props) => { // Use a layout effect to trigger the process of calculating the truncated text, for the // initial render. - React.useLayoutEffect(() => { - calculateTargetStyle(); + React.useEffect(() => { + window.requestAnimationFrame(calculateTargetStyle); }, [calculateTargetStyle]); // If the container has just been resized, recalculate. @@ -87,7 +87,9 @@ const Container = styled.div` */ const calculateMiddleTruncatedText = (container: HTMLDivElement, text: string) => { const font = getComputedStyle(container).font; - const width = container.getBoundingClientRect().width; + + // https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements#how_much_room_does_it_use_up + const width = container.offsetWidth; const body = document.body; diff --git a/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx b/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx index 5b0ba917288d1..4a5aef68936ab 100644 --- a/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx +++ b/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx @@ -45,6 +45,36 @@ export const Simple = () => { ); }; +export const TransformedContainerUsage = () => { + return ( + + + Note: Only the first item should appear truncated. This use case is based on our usage of + MiddleTruncate in modals that animate in. + + {[ + 'asset_that_supports_partition_ranges', + 'asset_downstream', + 'asset_weekly_root', + 'asset_weekly', + ].map((text) => ( + + + + + + + + + ))} + + ); +}; + export const FlexboxContainerUsage = () => { return ( @@ -85,6 +115,7 @@ export const FlexboxContainerUsage = () => { ); }; + export const TagUsage = () => { return ( diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/AssetKeysDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/AssetKeysDialog.tsx index 723c8bb7ae9be..b60fdfea0bb98 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/AssetKeysDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AutoMaterializePolicyPage/AssetKeysDialog.tsx @@ -22,7 +22,7 @@ export const AssetKeysDialog = (props: Props) => { setIsOpen(false)} - style={{width: '750px', maxWidth: '80vw', minWidth: '500px', transform: 'scale(1)'}} + style={{width: '750px', maxWidth: '80vw', minWidth: '500px'}} canOutsideClickClose canEscapeKeyClose > diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/BackfillPreviewModal.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/BackfillPreviewModal.tsx index d0b0eb7f6be11..31607e4e01b28 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/BackfillPreviewModal.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/BackfillPreviewModal.tsx @@ -65,16 +65,12 @@ export const BackfillPreviewModal = ({ ); }, [data]); - // BG Note: The transform: scale(1) below fixes a bug with MiddleTruncate where the text size - // is measured while the dialog is animating open and the scale is < 1, causing it to think - // it needs to truncate. A more general fix for this seems like it'll require a lot of testing. - return ( setOpen(false)} - style={{width: '90vw', maxWidth: 1100, transform: 'scale(1)'}} + style={{width: '90vw', maxWidth: 1100}} >