Skip to content

backgroundSize strings holding cover or contain lose every size, while the array form keeps the keyword #60214

Open

Description

@YevheniiKotyrlo

Description

processBackgroundSize returns [] for any backgroundSize string holding cover or contain (L35-L73), so backgroundSize: '10px auto, cover' leaves the view with no background size at all, the 10px auto layer included.

The array form of the same value, [{x: 10, y: 'auto'}, 'cover'], comes back unchanged, and the C++ conversion of backgroundSize reads cover and contain (conversions.h L796-L849). CSS's <bg-size> takes both keywords, and for an image with no natural aspect ratio, such as a gradient, both size it to the background positioning area (CSS Images 3, cover and contain constraint sizing).

processBackgroundSize-itest.js pins both keywords as unsupported (L220-L226), since #55904. On Android, BackgroundSize.parse reads only the object form (L136-L151).

Steps to reproduce

  1. Clone the reproducer and run bash repro.sh in it (Node 22 or later). It downloads react-native@0.88.1 and react-native@0.90.0-nightly-20261122-d6ea9fc1e (main at d6ea9fc) from npm, strips the Flow types from Libraries/StyleSheet/processBackgroundSize.js, and calls processBackgroundSize with five values.
  2. It exits 1 while a string holding cover or contain comes back without them, and 0 once every value gives its expected result.

Expected: '10px auto, cover' gives [{x: 10, y: 'auto'}, 'cover'], as the array form does, and 'cover' and 'contain' give ['cover'] and ['contain']; strings without the keywords keep their results.
Seen: all three strings give [], on 0.88.1 and on the nightly.

React Native Version

0.88.1, and 0.90.0-nightly-20261122-d6ea9fc1e

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx @react-native-community/cli info

node v26.12.1, win32 x64

Stacktrace or Logs

react-native@0.90.0-nightly-20261122-d6ea9fc1e (gitHead d6ea9fc1eed3da1bbb74d8a8ad77d539c430a7cf):
  processBackgroundSize("10px auto, 50%") -> [{"x":10,"y":"auto"},{"x":"50%","y":"auto"}]
  processBackgroundSize([{"x":10,"y":"auto"},"cover"]) -> [{"x":10,"y":"auto"},"cover"]
  processBackgroundSize("cover") -> [], expected ["cover"]
  processBackgroundSize("contain") -> [], expected ["contain"]
  processBackgroundSize("10px auto, cover") -> [], expected [{"x":10,"y":"auto"},"cover"]
Summary: react-native@0.88.1 (gitHead c30b7f86850d47422637a64c70508e7411dbd8ea): a string holding cover or contain loses its sizes; react-native@0.90.0-nightly-20261122-d6ea9fc1e (gitHead d6ea9fc1eed3da1bbb74d8a8ad77d539c430a7cf): a string holding cover or contain loses its sizes; exit 1

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/background-size-string-drops-cover-and-contain

Screenshots and Videos

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions