Skip to content

Default omitted filter amounts to 1 and reject px in processFilter - #59608

Merged
javache merged 1 commit into
react:mainfrom
lazerg:fix/issue-59604-filter-amount
Oct 29, 2026
Merged

javache merged 1 commit into
react:mainfrom
lazerg:fix/issue-59604-filter-amount

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary:

processFilter read an omitted amount as 0. ARGS_WITH_UNITS_REGEX matches an empty string and Number('') is 0, so brightness() painted the view black and opacity() hid it. It also accepted px for brightness, contrast, grayscale, invert, opacity, saturate and sepia, so brightness(2px) was applied as brightness(2).

These seven functions now default an empty amount to 1 and reject px, which is what CSS Filter Effects says and what the native CSSFilter parser already does (see the brightness_default and bightness_length cases in CSSFilterTest.cpp). blur() and hue-rotate() already fell back to 0, which is their CSS default, so they don't change.

Fixes #59604

Changelog:

[GENERAL] [FIXED] - filter functions like brightness() with no amount now default to 1 instead of 0, and px amounts are rejected for them

Test Plan:

In processFilter-itest.js I changed the px case of testStandardFilter to expect no filters and added a () case that expects an amount of 1. I ran the file through plain Jest (without the Fantom environment import): 21 cases fail on main and all 116 pass with this change. Flow, ESLint and Prettier are clean. I didn't run the Fantom runner or the reproducer on a device.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

1 visual difference(s) at 86d4c7eba228. Visual differences need maintainer approval. Review the report, then apply visual-change-approved.

ios button/default-styling/default: Changed, 38223 px (1.533%)

diff

Expected and Captured
Expected Captured
expected captured

@javache
javache merged commit 888784c into react:main Oct 29, 2026
101 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

filter strings: brightness() paints black, and brightness(2px) is accepted

2 participants