feat(core): support max-width and max-height CSS properties#11300
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit bc41f86
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
Add `max-width` / `max-height` style properties on iOS and Android, accepting fixed lengths and percentages (e.g. `max-width: 100%`), the CSS-standard complement to the existing `min-width` / `min-height`. Because percentages resolve against the parent size, the properties follow the `width`/`height` pattern rather than `min-*`: the effective pixel value is computed at measure time in `_updateEffectiveLayoutValues` (stored as `effectiveMaxWidth`/`effectiveMaxHeight`, defaulting to Infinity = unconstrained). Applied after the min clamp so `max` wins when `min > max`, matching CSS. iOS: measure-time clamps in the base view, all layout containers, and a central cap in `ViewHelper.getMeasureSpec`; wires up the long-dead `MAX_SIZE /* lp.maxWidth */` flexbox placeholders. Android: enforced natively in the widgets library — `maxWidth`/`maxHeight` (+percent) on `CommonLayoutParams`, clamped in `getMeasureSpec` and resolved in `adjustChildrenLayoutParams`, exposed via new `ViewHelper` setters. Removes the now-shadowing `maxWidth`/`maxHeight` fields from `FlexboxLayout.LayoutParams` so flexbox inherits the unified fields and honors the properties (including percent). Requires rebuilding `widgets-release.aar`. Adds automated tests for style-property parsing/sync, flexbox measure (enabling four previously-stubbed tests), StackLayout measure, and Label max-width/height including percent.
599fd0a to
bc41f86
Compare
Contributor
|
I leave this here for future reference since most people think that {N} fully supports minWidth/minHeight. In simple words, {N} minWidth/minHeight will have no effect if users sets width/height to a fixed size due to how android uses these properties along with its measure modes. |
NathanWalker
approved these changes
Jul 3, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
What is the current behavior?
NativeScript supports
width,height,min-widthandmin-height, but there is nomax-width/max-height. There is no way to cap a view's size — including the common responsivemax-width: 100%pattern. The Android flexbox port even contained deadMAX_SIZE /* lp.maxWidth */placeholders showing the feature was anticipated but never wired up.What is the new behavior?
Adds first-class
max-width/max-heightstyle properties on both iOS and Android, accepting fixed lengths and percentages (e.g.max-width: 200,max-width: 50%).Because percentages resolve against the parent size, the properties follow the
width/heightpattern rather thanmin-*: the effective pixel value is computed at measure time (effectiveMaxWidth/effectiveMaxHeight, defaulting to Infinity = unconstrained). The max clamp is applied after the min clamp, somaxwins whenmin > max, matching CSS.ViewHelper.getMeasureSpec; wires up the previously-deadMAX_SIZEflexbox placeholders.org.nativescript.widgetslibrary —maxWidth/maxHeight(+percent) onCommonLayoutParams, clamped ingetMeasureSpecand resolved inadjustChildrenLayoutParams, exposed via newViewHelpersetters. The now-shadowingmaxWidth/maxHeightfields were removed fromFlexboxLayout.LayoutParamsso flexbox inherits the unified fields and honors the properties (including percent).widgets-release.aarwas rebuilt.Adds automated tests for style-property parsing/sync, flexbox measure (enabling four previously-stubbed max tests), StackLayout measure, and Label max-width/height including percent.
Implements #1511
Implements #6441