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

two-way binding not working properly #38

Closed
ghost opened this issue Nov 29, 2013 · 14 comments
Closed

two-way binding not working properly #38

ghost opened this issue Nov 29, 2013 · 14 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Nov 29, 2013

If you edit the text, and them change the model, the text-angular does not change.

<div ng-init='test="hello world"'>
  <input type="text" ng-model="test"></input>
  <text-angular ng-model="test"/>
  <button ng-click="test='hello world'">reset</button>
</div>

If you write something in the textbox and then click the reset button, it works fine.

If you write something in the textangular and then click the reset button, it does not work.

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 29, 2013

Hi There, Thanks for opening an issue!

I'm having trouble replicating this, my example is here: http://codepen.io/SimeonC/pen/ftJyg
Can you give me some more information on how to make this occur please?

@ghost
Copy link
Author

ghost commented Nov 29, 2013

I will try to do my best, but my english is not as good as i'd like.

Write 'something' in the textangular widget.
The textbox has 'something'
Press the reset button.
The textbox has 'hello world'
the textangular has 'hello world'
Write again 'something' in the textangular
Press again the reset button
The textbox has 'hello world' but the textangular has 'something'

By the way, textAngular is awesome, and i will be happy to be helpul.

Hi There, Thanks for opening an issue!

I'm having trouble replicating this, my example is here:
http://codepen.io/SimeonC/pen/ftJyg
Can you give me some more information on how to make this occur please?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/38#issuecomment-29539063
.

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 29, 2013

Thanks, those steps are what I needed. I can see the problem now.
I'll get back to you when I've investigated some more.

@SimeonC
Copy link
Collaborator

SimeonC commented Nov 29, 2013

OK, this is fixed in some of the changes I've been making to fix other issues.
I'll be releasing a 1.1.1 1.1.2 version soon which will have the fix.

@SimeonC SimeonC closed this as completed Nov 29, 2013
@dapids
Copy link
Contributor

dapids commented Dec 4, 2013

Hello @SimeonC,

Can you confirm that this was fixed in the 1.1.1? I'm using the 1.1.1 and I'm still experiencing the issue.

Congrats for your work guys. Textangular is just great! ;)

@SimeonC
Copy link
Collaborator

SimeonC commented Dec 5, 2013

Hi @dapids.

This is what I get for releasing other important fixes and not checking closed commits. No it's not fixed in 1.1.1 - The other issues are to do with this are some HTML parsing and they are being a pain to fix so I ended up releasing an interim version with 1.1.1 with some other fixes - Namely #30. I'm hoping to get this done in the next week or so and release with 1.1.2.

Sorry about the Confusion! I'll try to be more consistent in future.

@SimeonC SimeonC reopened this Dec 5, 2013
SimeonC pushed a commit to SimeonC/textAngular that referenced this issue Dec 5, 2013
…r#30, textAngular#19

Updates the fix introduced in textAngular#5 to be more specific and less of a catch all.
Changed version to v1.1.2
@SimeonC
Copy link
Collaborator

SimeonC commented Dec 5, 2013

I'm going to close this with the release of the 1.1.2-alpha. If that doesn't fix it for you please do re-open the issue.

@SimeonC SimeonC closed this as completed Dec 5, 2013
netbubu17 pushed a commit to netbubu17/textAngular that referenced this issue Dec 19, 2013
…r#30, textAngular#19

Updates the fix introduced in textAngular#5 to be more specific and less of a catch all.
Changed version to v1.1.2
@DinkDonk
Copy link

I am experiencing this same bug in 1.2.2.
A text-angular element is behaving differently from a normal textarea element

A normal textarea element behaves like this:

  1. User focuses textarea, and types something
  2. Application (with intent) updates textarea's model while textarea is focused
  3. textarea content is updated to model value

A text-angular element behaves like this:

  1. User focuses textarea, and types something
  2. Application (with intent) updates textarea's model while textarea is focused
  3. textarea content is not updated to model value

@igmcdowell
Copy link

I'm also seeing this issue in 1.2.2 and head of the 1.3 branch. I tracked it down to this conditional in the ngModel.$render override:

if(!scope._elementSelectTriggered && $document[0].activeElement !== scope.displayElements.html[0] && $document[0].activeElement !== scope.displayElements.text[0]){
  // catch model being null or undefined
  scope.html = ngModel.$viewValue || '';
}

The specific problem is if the ngModel value updates from a background operation while the textangular element has focus. The above conditional fails the check for $document[0].activeElement !== scope.displayElements.html[0] , and skips updating scope.html.

I did experiment with changing the conditional, but there's a second spot in the codebase that has a similar check, the ngModel.render function for the taBind directive.

ngModel.$render = function(){
  // catch model being null or undefined
  var val = ngModel.$viewValue || '';
  // if the editor isn't focused it needs to be updated, otherwise it's receiving user input
  if($document[0].activeElement !== element[0]){
  ...

It seems like both of these blocks would need to change the conditionals to not rely on checking activeElement to resolve this issue. I don't feel like I have a good enough understanding of the codebase to know if there's a good alternative to checking activeElement, otherwise I'd submit a PR.

@SimeonC SimeonC reopened this Oct 29, 2014
@SimeonC
Copy link
Collaborator

SimeonC commented Oct 29, 2014

From memory the problem was that if we don't have that check then we end up with an infinite loop of model updates view updates model etc. I'll have another look into it soon.

@SimeonC
Copy link
Collaborator

SimeonC commented Feb 5, 2015

Landed in v1.3.6

@hcientist
Copy link

Is this still fixed (like in in 1.3.11)? #660 may be related

@SimeonC
Copy link
Collaborator

SimeonC commented May 10, 2015

Yup. Looks like it got back in somehow.

@adityapatadia
Copy link

I am getting similar issue. When the mode changes, the editor does not show changes. When I either focus or remove focus from textarea, it gets reflected. Can't we have the changes displayed immediately as the model is changing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants