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

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

Projects

None yet

5 participants

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

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 from Auto update input values from component after edited it with User? to Auto update input values after edited it with User? Nov 26, 2016
@Dreamvention
Dreamvention commented Nov 26, 2016 edited

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
believer-ufa commented Nov 26, 2016 edited

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

@Joylei
Contributor
Joylei commented Nov 26, 2016

it seems a bug.

plays well with 2.x.x

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

@cognitom
Member

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
Contributor
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
Member
cognitom commented Nov 26, 2016 edited

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

isValueAttr = attrName === 'riot-value'

I'll send PR, soon.

@cognitom cognitom referenced this issue Nov 26, 2016
Merged

Fix #2096 #2099

@GianlucaGuarini GianlucaGuarini pushed a commit that closed this issue Nov 26, 2016
@cognitom cognitom Fix #2096 001c253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment