Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(forms): Improve reactive errors #55395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 194 commits into from

Conversation

fdonzello
Copy link
Contributor

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Right now, when a form control is used without a parent form group, we get an error not reporting the form control name affected by the issue.
With long forms, it could take a lot of time to get the affected form control.
Screenshot 2024-04-18 at 12 19 31

What is the new behavior?

The console error has been improved by reporting either the form control name or index affected by the issue.
Screenshot 2024-04-18 at 16 06 44

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This is a starting point and can be further improved or scaled to other methods involved in form wrong usage.

pkozlowski-opensource and others added 30 commits March 6, 2024 20:40
This fixes and error that has been seen recently where compilation fails
due to domino.impl type not being recognized

PR Close angular#54736
This is not needed any longer since the changes that used it have
landed.

PR Close angular#54740
…4746)

This update modifies the transfer cache logic to prevent caching of HTTP requests that require authorization.

Closes: angular#54745

PR Close angular#54746
In order to serialize and hydrate i18n blocks, we need to be able to walk an AST for the translated message. This AST is generated during normal parsing of the message.

PR Close angular#54724
In preparation for hydration support, make sure that we don't attempt to hydrate detached nodes and instead, always newly create them.

PR Close angular#54723
Generated `events.json` with the latest events retrieved from the Firebase DB.

PR Close angular#54721
…ngular#54722)

Adds a `locateOrCreateNode` helper and uses it for all DOM operations in preparation for supporting hydration.

PR Close angular#54722
…ular#54083)

This commit updates the `afterRender` and `afterNextRender` hooks to
notify the scheduler (which subsequently schedules change detection)
when created. This makes the hooks similar to `requestAnimationFrame`,
which requests that the browser schedule a rendering operation. This
reqeust is not conditional. Even if there was nothing to repaint, the
`requestAnimationFrame` callback will execute.

In Angular, this is useful because callers of `afterNextRender` don't
necessarily have any way of knowing whether a change detection is even
scheduled. For example, the anchor scrolling with the Angular Router
needs to wait for rendering to complete before attempting to scroll
because rendering can affect the size of the page. However, if the user
is already on the page that the navigation is targeting, such as
navigating to an anchor on the page, there is nothing new for the Router
to render so a render might not even be scheduled.

Related to angular#53985, which
could use `afterNextRender` instead of `setTimeout` to ensure the
scrolling happens in the same frame as the page rendering, but would not
necessarily work without this change (as described above). Note that the
scrolling _cannot_ use a microtask to ensure scrolling happens in the
same frame because `NgZone` will ensure microtasks flush before
change detection, so it would cause the scroll to happen before rendering.

PR Close angular#54083
…ication source (angular#54083)

Do not refresh views if the only thing that notified the scheduler was
registration of a new render hook.

PR Close angular#54083
…ch (angular#54083)

This commit ensures that render hooks are rerun when a node is attached
or detached. We do not necessarily need to run change detection but DOM
did change so render hooks should execute.

PR Close angular#54083
…el previous navigation (angular#54710)

There is an edge case where synchronous navigations caused in
response to navigation events can result in a previous navigation not
being unsubscribed from. b/328219996

PR Close angular#54710
Fixes a broken size CI check.

PR Close angular#54756
The assertion in `packages/core/test/acceptance/after_render_hook_spec.ts:165` was prone to flakes,
where Jasmine could frequently report an error:

```
Error: 'expect' was used when there was no current spec, this could be because an asynchronous test timed out
    at Env.expect (node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1945:15)
    at expect (node_modules/jasmine-core/lib/jasmine-core/jasmine.js:8267:18)
    at file:///packages/core/test/acceptance/after_render_hook_spec.ts:165:12
```

This happens because `wrapTestFn` checks for an exact type of `Promise`, which may have been patched by zone.js
such that the `instanceof` condition is dependent on whether zone.js has patched the `Promise` constructor.

PR Close angular#54801
…rs (angular#54801)

This commit addresses a typing mismatch, where these functions were declared to return whichever
value their callback returned, but this was inaccurate: it's always a test callback function
with `done` argument.

PR Close angular#54801
angular#54801)

The `runCallbackOnce` closure is declared not to have any parameters itself, so it is
compatible as `queueMicrotask` callback without the extra closure. This reduces the call
stack by a frame and avoids the extra closure allocation.

PR Close angular#54801
Updates the repo to the stable version of TypeScript 5.4.

PR Close angular#54743
…lar#54772)

Fixes that the template parser wasn't catching empty expressions in the `track` parameter of for loops.

Fixes angular#54763.

PR Close angular#54772
…#54714)

Introduces a new `TemplateSemanticsChecker` that will be used to flag semantic errors in the user's template. Currently we do some of this in the type check block, but the problem is that it doesn't have access to the template type checker which prevents us from properly checking cases like angular#54670. This pass is also distinct from the extended template checks, because we don't want users to be able to turn the checks off and we want them to run even if `strictTemplates` are disabled.

PR Close angular#54714
…54714)

Moves the function that identifies signals into a separate file so that it can be reused outside of extended diagnostics.

PR Close angular#54714
…emplate semantics checker (angular#54714)

Moves the check which ensures that there are no writes to template variables into the `TemplateSemanticsChecker` to prepare for the upcoming changes.

PR Close angular#54714
…lates (angular#54714)

We have a diagnostic that reports writes to template variables which worked both for regular event bindings and two-way bindings, however the latter was broken by angular#54154 because two-way bindings no longer had a `PropertyWrite` AST.

These changes fix the diagnostic and expand it to allow two-way bindings to template variables that are signals.

PR Close angular#54714
…bles in instruction generation (angular#54714)

Updates the instruction generation for two-way bindings to only emit the `twoWayBindingSet` call when writing to template variables. Since template variables are constants, it's only allowed to write to them when they're signals. Non-signal values are flagged during template type checking.

Fixes angular#54670.

PR Close angular#54714
This commit removes uses of isG3 in the patch branch. G3 always executes
against main so any references in patch are unused.

PR Close angular#54816
…gular#54750)

An i18n message effectively acts as a dynamic template: two elements with contiguous instruction indices won't necessarily be contiguous in the DOM.

For that reason, we need to maintain a mapping from instruction index to a physical DOM node in order to hydrate views with i18n, pointing to where hydration for that view should begin.

PR Close angular#54750
…r#54425)

This commit updates HTML sanitization logic to avoid infinite loops in case clobbered elements contain fields like `nextSibling` or `parentNode`. Those fields are used for DOM traversal and this update makes sure that those calls return valid results.

Also this commit fixes an issue when clobbering `nodeName` causes JS exceptions.

PR Close angular#54425
jelbourn and others added 7 commits April 12, 2024 10:10
…ular#55308)

Adds a brief team doc for when to use developer preview and experimental
API tags.

PR Close angular#55308
When we started fixing the version mismatch with local 1st-party
packages, we also re-routed all dependencies like `@lezer/javascript`
into `adev/node_modules`. This works fine, but results in a different
version mismatch because the codemirror dependencies may resolve the
Angular version from `/node_modules`- causing some subtle complex
runtime error.

This commit fixes this by only re-routing dependencies that have
dependency on e.g. `@angular/core` into `adev/node_modules`.

Fixes angular#55298.

PR Close angular#55349
When a formControlName is used without a parent formGroup, an error is
logged in the console. Before this commit, there was no information
about which control had the issue. Now, it's reported and the
troubleshoot is much faster.
@fdonzello fdonzello changed the title Improve reactive errors feat(forms): Improve reactive errors Apr 18, 2024
@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Apr 18, 2024
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: docs Related to the documentation area: build & ci Related the build and CI infrastructure of the project labels Apr 18, 2024
@ngbot ngbot bot added this to the Backlog milestone Apr 18, 2024
@geromegrignon
Copy link
Contributor

Hi @fdonzello, there is a problem with your git history: the PR should only includes your commit(s).

@josephperrott
Copy link
Member

Closing PR as it looks like the commit history involved here got a little messed up. Feel free to open another PR with these changes after rebasing your changes on the latest changes in our repository.

@fdonzello fdonzello deleted the improve-reactive-errors branch April 18, 2024 15:33
@fdonzello
Copy link
Contributor Author

oh yeah what a mess, sorry guys.

Here is the correct one: #55397

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: build & ci Related the build and CI infrastructure of the project area: docs Related to the documentation detected: feature PR contains a feature commit requires: TGP This PR requires a passing TGP before merging is allowed
Projects
None yet
Development

Successfully merging this pull request may close these issues.