Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Sep 8, 2025

This PR fixes a bug where custom @utility implementations with a name that match an existing utility would override the existing suggestions even though we generate both utilities.

With this, we want to make sure that both the custom and the built-in utilities are suggested. We also want to make sure that we don't get duplicate suggestions.

E.g.:

  • font- would suggest:
    • 'font-black'
    • 'font-bold'
    • 'font-extrabold'
    • 'font-extralight'
    • 'font-light'
    • 'font-medium'
    • 'font-mono'
    • 'font-normal'
    • 'font-sans'
    • 'font-semibold'
    • 'font-serif'
    • 'font-thin'

But if you introduce this little custom utility:

@theme {
  --custom-font-weights-foo: 123;
}

@utility font-* {
  --my-weight: --value(--custom-font-weights- *);
}
  • font- would suggest:
    • 'font-foo'

With this fix, we would suggest:

  • font- would suggest:
    • 'font-black'
    • 'font-bold'
    • 'font-extrabold'
    • 'font-extralight'
    • 'font-foo' // This is now added
    • 'font-light'
    • 'font-medium'
    • 'font-mono'
    • 'font-normal'
    • 'font-sans'
    • 'font-semibold'
    • 'font-serif'
    • 'font-thin'

We also make sure that they are unique, so if you have a custom utility that happens to match another existing utility (e.g. font-bold), you won't see font-bold twice in the suggestions.

@theme {
  --custom-font-weights-bold: bold;
  --custom-font-weights-normal: normal;
  --custom-font-weights-foo: 1234;
}

@utility font-* {
  --my-weight: --value(--custom-font-weights-*);
}
  • font- would suggest:
    • 'font-black'
    • 'font-bold' // Overlaps with existing utility
    • 'font-extrabold'
    • 'font-extralight'
    • 'font-foo' // This is now added
    • 'font-light'
    • 'font-medium'
    • 'font-mono'
    • 'font-normal' // Overlaps with existing utility
    • 'font-sans'
    • 'font-semibold'
    • 'font-serif'
    • 'font-thin'

@RobinMalfait RobinMalfait requested a review from a team as a code owner September 8, 2025 10:04
When existing suggestions exist, and you have a custom `@utility` with a
matching root, then we would override the existing utilities which is
wrong.

This ensures that we merge all the groups such that all utilities are
being suggested to the user.
For the `mask-*` utilities, we do call `suggest(…)` multiple times, so
there could be some duplication. The `modifiers` are a simple array and
not a Set so let's make them unique here.

Ideally we don't call suggest with the same values, but that requires a
bigger internal refactor.

Another ideal situation would be if `modifiers` was a Set in the first
place. But since it's export and "public" API I didn't want to change
that datastructure.
@RobinMalfait RobinMalfait merged commit 2f1cbbf into main Sep 8, 2025
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/merge-suggestions branch September 8, 2025 10:18
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.