Title: NG8011: Node matches the X slot of the Y component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root. · Issue #54077 · angular/angular · GitHub
Open Graph Title: NG8011: Node matches the X slot of the Y component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root. · Issue #54077 · angular/angular
X Title: NG8011: Node matches the X slot of the Y component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root. · Issue #54077 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description I have the following code which causes a warning during compilation, but the warning suggests fixes that don't apply to the code in que...
Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description I have the following code which causes a warning during compilation, but the warning suggests f...
X Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description I have the following code which causes a warning during compilation, but the warning suggests f...
Opengraph URL: https://github.com/angular/angular/issues/54077
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NG8011: Node matches the X slot of the Y component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root.","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\ncompiler\r\n\r\n### Is this a regression?\r\n\r\nYes\r\n\r\n### Description\r\n\r\nI have the following code which causes a warning during compilation, but the warning suggests fixes that don't apply to the code in question.\r\n\r\n```html\r\n \u003cmat-form-field subscriptSizing=\"dynamic\">\r\n \u003cmat-label>Phone Number\u003c/mat-label>\r\n \u003cinput\r\n matInput\r\n [formControl]=\"form.controls.phoneNumber\"\r\n required\r\n type=\"tel\"\r\n />\r\n @if (form.controls.phoneNumber.hasError('isPhoneNumber')) {\r\n \u003cmat-error>Must be a valid U.S. phone number\u003c/mat-error>\r\n }\r\n \u003c/mat-form-field>\r\n```\r\n\r\nThis caused the following compiler warning, followed by some suggestions to fix it.\r\n\r\n> NG8011: Node matches the \"mat-error, [matError]\" slot of the \"MatFormField\" component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root.\r\n\r\nThe bug here is that **there is not more than one node at the root of the @if**. Suggestion 1 is basically already in-place, suggestion 2 is impossible, and section 3 is already in-place.\r\n\r\nNote that this is not a duplicate of #53477, because #53477 is a case where the content does need to be split/wrapped.\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\n_No response_\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```true\r\nThe compiler error is as follows:\r\n\r\n\r\nWarning: src/app/@shared/send-it/send-it.component.html:14:7 - warning NG8011: Node matches the \"mat-error, [matError]\" slot of the \"MatFormField\" component, but will not be projected into the specific slot because the surrounding @if has more than one node at its root. To project the node in the right slot, you can:\r\n\r\n1. Wrap the content of the @if block in an \u003cng-container/> that matches the \"mat-error, [matError]\" selector.\r\n2. Split the content of the @if block across multiple @if blocks such that each one only has a single projectable node at its root.\r\n3. Remove all content from the @if block, except for the node being projected.\r\nNote: the host component has `preserveWhitespaces: true` which may cause whitespace to affect content projection.\r\n\r\nThis check can be disabled using the `extendedDiagnostics.checks.controlFlowPreventingContentProjection = \"suppress\" compiler option.`\r\n\r\n14 \u003cmat-error>Must be a valid U.S. phone number\u003c/mat-error>\r\n ~~~~~~~~~~~\r\n\r\n src/app/@shared/send-it/send-it.component.ts:15:16\r\n 15 templateUrl: './send-it.component.html',\r\n ~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n Error occurs in the template of component SendItComponent.\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 17.1.1\r\nNode: 18.18.0\r\nPackage Manager: yarn 1.22.19\r\nOS: darwin arm64\r\n\r\nAngular: 17.1.0\r\n... animations, cdk, common, compiler, compiler-cli, core, forms\r\n... language-service, localize, material, platform-browser\r\n... platform-browser-dynamic, router, service-worker\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1701.1\r\n@angular-devkit/build-angular 17.1.1\r\n@angular-devkit/core 17.1.1\r\n@angular-devkit/schematics 17.1.1\r\n@angular/cli 17.1.1\r\n@angular/pwa 17.1.1\r\n@schematics/angular 17.1.1\r\nrxjs 7.8.1\r\ntypescript 5.3.3\r\nzone.js 0.14.3\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nThis happens in many other similar (one root node inside the `@if`) instances--not always MatFormField, even--across my application.","author":{"url":"https://github.com/Kerrick","@type":"Person","name":"Kerrick"},"datePublished":"2024-01-25T17:21:14Z","url":"https://github.com/angular/angular/issues/54077"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2d3f9230-62e5-23e5-24b3-99122cb6d7fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3E8:D0E46:1296B42:188BEA5:6B011A01 |
| html-safe-nonce | d19098fbc48a0c35112b131762804585d7abb4f925640f4c1c71f41aac2b9a40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0U4OkQwRTQ2OjEyOTZCNDI6MTg4QkVBNTo2QjAxMUEwMSIsInZpc2l0b3JfaWQiOiIxMDE4NjcyMDUxNDc4NjY1NzI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 29eb9449aeb8599fa338cf942884e529443041f37f56775d52cccbb05deee295 |
| hovercard-subject-tag | issue:2100847504 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/54077/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f8229e94b752ecd034b8c2c77c8c3d32bc5736eef83e7211de40541ac2ca1e7/angular/angular/issues/54077 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f8229e94b752ecd034b8c2c77c8c3d32bc5736eef83e7211de40541ac2ca1e7/angular/angular/issues/54077 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? compiler Is this a regression? Yes Description I have the following code which causes a warning during compilation, but the warning suggests f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Kerrick |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width