diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c37104d86a..b06102bc1006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Disallow multiple selectors in arbitrary variants ([#10655](https://github.com/tailwindlabs/tailwindcss/pull/10655)) - Sort class lists deterministically for Prettier plugin ([#10672](https://github.com/tailwindlabs/tailwindcss/pull/10672)) - Ensure CLI builds have a non-zero exit code on failure ([#10703](https://github.com/tailwindlabs/tailwindcss/pull/10703)) +- Remove blocklisted classes from autocomplete ([#10844](https://github.com/tailwindlabs/tailwindcss/pull/10844)) ### Changed diff --git a/src/lib/setupContextUtils.js b/src/lib/setupContextUtils.js index 0749da68dbdc..e17ba43c1096 100644 --- a/src/lib/setupContextUtils.js +++ b/src/lib/setupContextUtils.js @@ -1007,6 +1007,11 @@ function registerPlugins(plugins, context) { } } + // Exclude utilities that are known non-classes (e.g. from the blocklist) + if (context.notClassCache.size > 0) { + output = output.filter((cls) => !context.notClassCache.has(cls)) + } + return output } diff --git a/tests/getClassList.test.js b/tests/getClassList.test.js index 671a767ecfe5..06e8dd345538 100644 --- a/tests/getClassList.test.js +++ b/tests/getClassList.test.js @@ -191,6 +191,18 @@ crosscheck(() => { expect(classes).not.toContain('bg-red-500/50') }) + it('should not generate utilities that are present in the blocklist', () => { + let config = { + blocklist: ['font-bold'], + } + + let context = createContext(resolveConfig(config)) + let classes = context.getClassList() + + expect(classes).toContain('font-normal') + expect(classes).not.toContain('font-bold') + }) + it('should not generate utilities that are set to undefined or null to so that they are removed', () => { let config = { theme: {