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

Comments

Projects
None yet
5 participants
@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 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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost 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
})

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

This comment has been minimized.

Show comment
Hide comment
@believer-ufa

believer-ufa 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.

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

This comment has been minimized.

Show comment
Hide comment
@Joylei

Joylei Nov 26, 2016

Contributor

it seems a bug.

plays well with 2.x.x

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

Contributor

Joylei commented Nov 26, 2016

it seems a bug.

plays well with 2.x.x

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

@cognitom

This comment has been minimized.

Show comment
Hide comment
@cognitom

cognitom Nov 26, 2016

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@Joylei

Joylei Nov 26, 2016

Contributor

@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

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

This comment has been minimized.

Show comment
Hide comment
@cognitom

cognitom Nov 26, 2016

Member

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

isValueAttr = attrName === 'riot-value'

I'll send PR, soon.

Member

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