Skip to content
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

Support for implicit deferred triggers and better diagnostics for triggers #51922

Closed
wants to merge 2 commits into from

Conversation

crisbeto
Copy link
Member

Adds support for viewport, hover and interaction deferred triggers with an implicit element reference, as well as a diagnostic for the case where the deferred block can't resolve its trigger element. Split up into the following commits:

fix(compiler): add diagnostic for inaccessible deferred trigger

If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users.

feat(core): support deferred triggers with implicit triggers

Adds support for defining viewport, interaction and hover triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the @placeholder block. Triggers with no parameters have the following restrictions:

  1. They have to be placed on an @defer block that has an @placeholder.
  2. The @placeholder can only have one root node.
  3. The root placeholder node has to be an element.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: major This PR is targeted for the next major release area: compiler Issues related to `ngc`, Angular's template compiler labels Sep 27, 2023
@crisbeto crisbeto added this to the v17-candidates milestone Sep 27, 2023
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Sep 27, 2023
If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users.
Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions:
1. They have to be placed on an `@defer` block that has an `@placeholder`.
2. The `@placeholder` can only have one root node.
3. The root placeholder node has to be an element.
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

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

LGTM, but curious about the requirement of a single root node.

reviewed-for: fw-core, public-api

// If the trigger doesn't have a reference, it is inferred as the root element node of the
// placeholder, if it only has one root node. Otherwise it's ambiguous so we don't
// attempt to resolve further.
return children !== null && children.length === 1 && children[0] instanceof Element ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just apply the trigger to every root node rather than require one?

Copy link
Member Author

Choose a reason for hiding this comment

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

What we'd talked about was that if there are multiple root nodes, it could lead to some weird situations like a closing icon positioned at the top of the container causing the entire thing to load. Binding to each root node can also be a problem for the interaction and hover triggers, because there could be text nodes in-between that won't fire any events.

@jessicajaniuk jessicajaniuk removed their request for review September 27, 2023 15:06
@pullapprove pullapprove bot requested a review from atscott September 27, 2023 15:06
@pullapprove pullapprove bot requested a review from atscott September 27, 2023 17:10
Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

reviewed-for: public-api

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 27, 2023
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

👍

@dylhunn
Copy link
Contributor

dylhunn commented Sep 27, 2023

This PR was merged into the repository by commit e2e3d69.

@dylhunn dylhunn closed this in 23bfa10 Sep 27, 2023
dylhunn pushed a commit that referenced this pull request Sep 27, 2023
Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions:
1. They have to be placed on an `@defer` block that has an `@placeholder`.
2. The `@placeholder` can only have one root node.
3. The root placeholder node has to be an element.

PR Close #51922
@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 Oct 28, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…lar#51922)

If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users.

PR Close angular#51922
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…#51922)

Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions:
1. They have to be placed on an `@defer` block that has an `@placeholder`.
2. The `@placeholder` can only have one root node.
3. The root placeholder node has to be an element.

PR Close angular#51922
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime detected: feature PR contains a feature commit target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants