fix(textinput): correct placeholder layout constraints (px vs DIP) and no-op NaN fontSize guard#16317
Open
FaithfulAudio wants to merge 2 commits into
Open
Conversation
…d no-op NaN fontSize guard Forward-port of microsoft#16303 (0.83-stable) to main. CreatePlaceholderLayout fed m_imgWidth/m_imgHeight - which are physical pixels (frame * pointScaleFactor) - into LayoutConstraints, which are expressed in DIPs. The placeholder was laid out in a box pointScaleFactor times too large, so it measured and positioned at a different height than the typed text. Divide by pointScaleFactor. The NaN fontSize guard was also a no-op: it evaluated defaultTextAttributes().fontSize as a discarded expression statement instead of assigning it, so a placeholder with no fontSize never picked up the default.
Contributor
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
Forward-port of #16303 (which targets
0.83-stable) tomain, per @acoates-ms:Both defects are present on
maintoday, inWindowsTextInputComponentView::CreatePlaceholderLayout().1. Placeholder layout constraints were fed physical pixels, not DIPs
m_imgWidth/m_imgHeightare physical pixels (frame * pointScaleFactor), butfacebook::react::LayoutConstraintsare expressed in DIPs. The placeholder was therefore laid out inside a boxpointScaleFactorx too large, so it measured and positioned at a different height than the typed text — visible as the placeholder sitting at a different baseline than the value the user types, and worsening as scale increases.This version divides directly, with no
!= 0guard — per review feedback on #16303.LayoutMetrics::pointScaleFactorhas a default member initializer of1.0andEmptyLayoutMetricsonly designates.frame, so even the pre-layout sentinel inherits1.0; there is no path here where it is0.2. The NaN
fontSizeguard was a no-opThe guard evaluated
defaultTextAttributes().fontSizeas a discarded expression statement rather than assigning it, so a placeholder with no explicitfontSizenever actually picked up the default:if (std::isnan(props.textAttributes.fontSize)) { - facebook::react::TextAttributes::defaultTextAttributes().fontSize; + textAttributes.fontSize = facebook::react::TextAttributes::defaultTextAttributes().fontSize; }Testing
Verified on the
0.83-stableversion of this change (#16303): compiled into a framework source build (binary-gated) and re-probed in a production app at 250% scale — no regression, the NaN-fontSize guard now actually assigns (a no-fontSize placeholder renders at the default size), and placeholder-vs-typed are pixel-comparable at that geometry. Evidence attached to #16303.This
mainport is the identical change applied to the currentmainsource; it has not been separately run on-device, so CI is the gate here.Related: #16303 (
0.83-stable).Microsoft Reviewers: Open in CodeFlow