Skip to content

downgraded component: not possible to have two-way binding and change event on the same output / emitter #22734

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
FDIM opened this issue Mar 13, 2018 · 6 comments
Labels
effort1: hours freq1: low help wanted An issue that is suitable for a community contributor (based on its complexity/scope). target: patch This PR is targeted for the next patch release type: bug/fix
Milestone

Comments

@FDIM
Copy link
Contributor

FDIM commented Mar 13, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

It seems that it is not possible to have 2-way-binding and listen to the same change event when angular 5 component is downgraded.

Expected behavior

Two way binding should work and the provided expression (if any) should be evaluated.

Minimal reproduction of the problem with instructions

  • open https://stackblitz.com/edit/ngupgradestatic-playground-o2xraa?file=index.html
  • click the first increment button and observe that only the value from event changes even though there is two-way binding to value property
  • clicking second increment button only updates counter as there is no additional binding to countChange output (all good)
  • after clicking 3rd button you can see that both values update (all good)

What is the motivation / use case for changing the behavior?

To keep downgraded component behavior similar to normal usage in other angular 5 component

Environment


Angular version: 5.2.x

Browser: any

@ngbot ngbot bot added this to the needsTriage milestone Mar 13, 2018
@gkalpak
Copy link
Member

gkalpak commented Mar 14, 2018

This is a valid issue. It happens, because of the if elses we have here, which only allow one form of the output binding and ignore the rest. Instead, we should collect all output bindings.

@FDIM, would you be interested in working on this?

@gkalpak gkalpak added type: bug/fix effort1: hours freq1: low target: patch This PR is targeted for the next patch release help wanted An issue that is suitable for a community contributor (based on its complexity/scope). labels Mar 14, 2018
@FDIM
Copy link
Contributor Author

FDIM commented Mar 14, 2018

@gkalpak I am :) I'll try come up with a fix in our local copy of the library (we have it due to another issue) and I'll prepare a PR after that. So hopefully some time this week.

EDIT: I already got a fix in my fork: https://github.com/FDIM/angular/tree/bugfix/two-way-binding-and-expressions-on-same-output
I'll prepare the PR a bit later in the evening (well at least in Europe)

@gkalpak
Copy link
Member

gkalpak commented Mar 14, 2018

From a quick look, the fix looks good 👍 (Make sure to include some tests on the PR 😉)
Feel free to ping me if you get stack.

FDIM added a commit to FDIM/angular that referenced this issue Mar 14, 2018
Changes would not propagate to value in downgraded component in case you had two-way binding and listening to model-change, e.g. [(model)]="value" (model-change)="fetch()"

Closes angular#22734
FDIM added a commit to FDIM/angular that referenced this issue Mar 14, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a model-change, e.g. [(model)]="value" (model-change)="fetch()"

Closes angular#22734
FDIM added a commit to FDIM/angular that referenced this issue Mar 14, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a model-change, e.g. [(model)]="value" (model-change)="fetch()"

Closes angular#22734
@FDIM
Copy link
Contributor Author

FDIM commented Mar 14, 2018

After fiddling with some white space (linter is very picky!) - I think the PR is ready.

I also updated existing test case and seen it break without my changes and pass with the fix.

@gkalpak
Copy link
Member

gkalpak commented Mar 14, 2018

Thx! I'll take a look shortly.
(Pro tip: gulp format fixes linting issues 😉)

FDIM added a commit to FDIM/angular that referenced this issue Mar 15, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a model-change, e.g. [(model)]="value" (model-change)="fetch()"

Closes angular#22734
FDIM added a commit to FDIM/angular that referenced this issue Mar 16, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a value-change, e.g. [(value)]="value" (value-change)="fetch()"

Closes angular#22734
mhevery pushed a commit that referenced this issue Mar 20, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a value-change, e.g. [(value)]="value" (value-change)="fetch()"

Closes #22734

PR Close #22772
leo6104 pushed a commit to leo6104/angular that referenced this issue Mar 25, 2018
Changes would not propagate to a value in downgraded component in case you had two-way binding and listening to a value-change, e.g. [(value)]="value" (value-change)="fetch()"

Closes angular#22734

PR Close angular#22772
@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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: hours freq1: low help wanted An issue that is suitable for a community contributor (based on its complexity/scope). target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants