Skip to content

Commit a42e9d6

Browse files
committed
Fix maxWidth not setting contain prop on text node properly in flex plugin
1 parent 393e728 commit a42e9d6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

.changeset/gentle-moments-speak.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plexinc/react-lightning-plugin-flexbox": patch
3+
---
4+
5+
Fix bug with maxWidth not setting contain property on text nodes

packages/plugin-flexbox/src/index.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {
22
LightningElement,
33
LightningElementStyle,
4-
LightningTextElement,
54
LightningViewElementStyle,
65
Plugin,
76
} from '@plexinc/react-lightning';
@@ -259,6 +258,7 @@ export function plugin(yogaOptions?: YogaOptions): Plugin<LightningElement> {
259258
computedWidth > 0 &&
260259
event.dimensions.width > computedWidth
261260
) {
261+
node.contain = 'width';
262262
node.width = computedWidth;
263263
}
264264
}
@@ -283,12 +283,6 @@ export function plugin(yogaOptions?: YogaOptions): Plugin<LightningElement> {
283283
return props;
284284
}
285285

286-
// purposely using a falsy check on maxWidth here, since we don't want the
287-
// contain mode set to `width` if it's set to 0 or an empty string
288-
if (props.style?.maxWidth && instance.node && instance.isTextElement) {
289-
(instance as LightningTextElement).node.contain = 'width';
290-
}
291-
292286
for (const key in remainingStyles) {
293287
const value = remainingStyles[key as keyof LightningViewElementStyle];
294288

0 commit comments

Comments
 (0)