ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

throttle and attr don't seem to work together #255

Closed jpdewing closed 8 years ago

jpdewing commented 8 years ago

Hi Manuel,

I might be doing something wrong or this is an edge case bug.

If you have an input that has an attr with a throttle set, and the user types something quickly and tabs away the viewmodel value does not update. It works fine without the attr...

example

<template name="binding">
  <input {{b "value: message, throttle: 400, attr: {placeholder: placeholder}"}} type="text">
  <div {{b "text: message"}} ></div>
</template>
ManuelDeLeon commented 8 years ago

I can't reproduce it. Make a repro.

jpdewing commented 8 years ago

Sorry was focus rather than attr that looks to be causing the problem please see https://github.com/jpdewing/vmThrottle for example.

If you type quickly and tab between fields it should illustrate the issue. It is using an older release but also has the same result in latest release 4.1.5

Thanks, James

ManuelDeLeon commented 8 years ago

Your repro works as advertised. I type, tab, 1 sec later label updates. Please try in different browsers.

jpdewing commented 8 years ago

Hmmm, odd. I get the same experience with chrome, FF and edge.

If I refresh the page, type into the first field then immediately tab to the next field and type again, only the last field updates after the throttle period.

However if I keep focus on the first field and let the throttle run then subsequent events fire ok on the first field. A bit difficult to explain I have recorded a quick demo of the behaviour http://recordit.co/mzjDT2ydaX

This does seem a bit obscure so don't worry about it, I can change the way I do the focus.

ManuelDeLeon commented 8 years ago

Closing this one, I may revisit it at a later point.