Skip to content

fix: remove transform keys before appending new ones#357

Closed
5ZYSZ3K wants to merge 3 commits into
nativewind:mainfrom
5ZYSZ3K:fix/transform-doubled-issue
Closed

fix: remove transform keys before appending new ones#357
5ZYSZ3K wants to merge 3 commits into
nativewind:mainfrom
5ZYSZ3K:fix/transform-doubled-issue

Conversation

@5ZYSZ3K

@5ZYSZ3K 5ZYSZ3K commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR aims to remove doubled translate-related objects in the transform array, as described in #356

Closes #356

Copilot AI review requested due to automatic review settings June 18, 2026 08:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes duplicated translate-related entries in React Native transform arrays by removing any existing transform objects whose keys will be appended next, preventing compounded transforms when multiple translate classNames are combined (issue #356).

Changes:

  • Expands transform cleanup logic to remove existing transform entries not only for the current prop, but also for any keys present in the incoming transform array value.

Comment thread src/native/objects.ts Outdated
Comment on lines +72 to +79
// Remove any existing values ​​and any keys that are to be appended next
target.transform = transformArray.filter((t) => !(prop in t));
const keysToRemove = Array.isArray(value)
? new Set(value.flatMap((v) => Object.keys(v)))
: new Set([prop]);
target.transform = transformArray.filter(
(t) => !(prop in t) && !Object.keys(t).some((k) => keysToRemove.has(k)),
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied the suggestions

Comment thread src/native/objects.ts
Comment on lines +74 to +79
const keysToRemove = Array.isArray(value)
? new Set(value.flatMap((v) => Object.keys(v)))
: new Set([prop]);
target.transform = transformArray.filter(
(t) => !(prop in t) && !Object.keys(t).some((k) => keysToRemove.has(k)),
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the test, but I realised that it would be passed even without my change - it wasn't enough to capture the regression, but I couldn't find why

@5ZYSZ3K

5ZYSZ3K commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

I found another issue: #358, and I guess that it might be necessary to target both of them at once

@5ZYSZ3K 5ZYSZ3K closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

translate classNames moving the component twice as far

2 participants