Skip to content

fix(popover-edit): incorrectly caching values for more than one control #16057

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

Merged
merged 1 commit into from
Jul 24, 2019

Conversation

crisbeto
Copy link
Member

Currently the edit popover uses the first valueChange event to know when to cache the value of its form so that it can revert to it if the user presess the revert button. This breaks down if the form has more than one control, because it'll emit a valueChange for each control that gets added. These changes fix the issue by using NgZone to wait for the form to be initialized.

@crisbeto crisbeto added pr: merge safe target: patch This PR is targeted for the next patch release labels May 19, 2019
@crisbeto crisbeto requested a review from andrewseguin as a code owner May 19, 2019 15:36
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 19, 2019
@@ -41,7 +41,8 @@ export class EditRef<FormValue> implements OnDestroy {

constructor(
@Self() private readonly _form: ControlContainer,
private readonly _editEventDispatcher: EditEventDispatcher) {
private readonly _editEventDispatcher: EditEventDispatcher,
private _ngZone: NgZone) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

readonly

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I'm on board with marking everything as readonly. This is a private property which is very unlikely to be changed by something internal. We haven't done it anywhere else in the library and we haven't run into any issues with it so far.

Copy link
Member

Choose a reason for hiding this comment

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

It's correct, though; we should be marking readonly way more than we do, we just never got in the habit of it

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed, although I feel like it's extremely unlikely that it'll actually catch anything. Furthermore since this is already private, if somebody wanted to override for some reason, there's nothing stopping them from just removing the readonly.

@crisbeto crisbeto force-pushed the popover-edit-revert branch 2 times, most recently from 83843c7 to 840181c Compare May 20, 2019 19:44
@crisbeto crisbeto added the P2 The issue is important to a large percentage of users, with a workaround label Jul 5, 2019
@crisbeto crisbeto force-pushed the popover-edit-revert branch from 840181c to adea7dc Compare July 5, 2019 20:53
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

Currently the edit popover uses the first `valueChange` event to know when to cache the value of its form so that it can revert to it if the user presess the `revert` button. This breaks down if the form has more than one control, because it'll emit a `valueChange` for each control that gets added. These changes fix the issue by using `NgZone` to wait for the form to be initialized.
@crisbeto crisbeto force-pushed the popover-edit-revert branch from adea7dc to 369d1b6 Compare July 24, 2019 20:32
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jul 24, 2019
@kseamon
Copy link
Collaborator

kseamon commented Jul 24, 2019

LGTM

@jelbourn jelbourn merged commit 13becda into angular:master Jul 24, 2019
andrewseguin pushed a commit that referenced this pull request Jul 29, 2019
…ol (#16057)

Currently the edit popover uses the first `valueChange` event to know when to cache the value of its form so that it can revert to it if the user presess the `revert` button. This breaks down if the form has more than one control, because it'll emit a `valueChange` for each control that gets added. These changes fix the issue by using `NgZone` to wait for the form to be initialized.
@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 Sep 11, 2019
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 cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants