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

Auto update input values after edited it with User? #2096

Closed
believer-ufa opened this issue Nov 26, 2016 · 6 comments
Closed

Auto update input values after edited it with User? #2096

believer-ufa opened this issue Nov 26, 2016 · 6 comments

Comments

@believer-ufa
Copy link

@believer-ufa believer-ufa commented Nov 26, 2016

If user edit input value manually, Riot.js dont changed it in future tag updates.

As i see, this is default browsers setAttribute method behaviour. If user is not edited input value, Browsers updates his visible value and his attribute. But! After manual edit input, setAttribute method changes only attribute value.

Example on plnkr: http://plnkr.co/edit/ybvigX18VUAOk4yKR7KI?p=preview

What think authors of Riot.js about this? Maybe make sence to think about it and create some functions to set input values through something like dom.value = {value} in setAttr method? Or this will be wrong approach?

On which browser/OS does the issue appear?

  • Google Chrome
  • Firefox

Which version of Riot does it affect?

  • 3.0

How would you tag this issue?

  • Question
  • Discussion
@believer-ufa believer-ufa changed the title Auto update input values from component after edited it with User? Auto update input values after edited it with User? Nov 26, 2016
@ghost
Copy link

@ghost ghost commented Nov 26, 2016

Hi

I had the same question yesterday and then it hit me - why not tell riot to update the value after update. I believe it is not riot but the browser that is not displaying the values to the user even though the value in the dom was updated.

here was my issue:
#2094

so simply do this http://plnkr.co/edit/3QQEj06ZuHDhPQPchCeD?p=preview

this.on('updated', function(){
    this.refs.input.value = this.message
})
@believer-ufa
Copy link
Author

@believer-ufa believer-ufa commented Nov 26, 2016

I know about it, thanks @Dreamvention :) Its just a questions to Riot.js authors to find out their opinion on the matter.

@Joylei
Copy link
Contributor

@Joylei Joylei commented Nov 26, 2016

it seems a bug.

plays well with 2.x.x

http://plnkr.co/edit/2WALxzd2s9gWyC9IT7n7?p=preview

@cognitom
Copy link
Member

@cognitom cognitom commented Nov 26, 2016

Yeah, it seems bug.
But bit weird. We have no change on setAttr() func...
https://github.com/riot/riot/blob/v2.6.7/lib/browser/tag/util.js

@Joylei
Copy link
Contributor

@Joylei Joylei commented Nov 26, 2016

@cognitom

I've debugged the code in chrome development tool, found that

  • dom.setAttribute('value', SOME_VALUE) did work, but it did not change dom.value, you can use dom.getAttribute('value') to get the value back
  • change dom.value, the display of input get updated

2016-11-26_21-37-14

@cognitom
Copy link
Member

@cognitom cognitom commented Nov 26, 2016

Maybe I've found the bug here. This line should be like this, maybe:

isValueAttr = attrName === 'riot-value'

I'll send PR, soon.

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

Successfully merging a pull request may close this issue.

None yet
4 participants