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) => {