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

[0.8] Binding the value of an input box with {{value::input}} loses caret index #1471

Closed
Sleeckx opened this issue Apr 30, 2015 · 1 comment

Comments

@Sleeckx
Copy link

Sleeckx commented Apr 30, 2015

When binding a value to an input box using the custom notify event syntax, you lose the caret index when adding a character. The selectionStart always jumps to the end.

<input value="{{value::input}}" />

http://jsbin.com/situwa/2/edit?html,output

When digging in the _effects.html_, the value of the input is set, even though it has the same value already.

_applyEffectValue: function(value, info) {
    var node = this._nodes[info.index];
    // TODO(sorvell): ideally, the info object is normalized for easy
    // lookup here.
    var property = info.property || info.name || 'textContent';
    // special processing for 'class' and 'className'; 'class' handled
    // when attr is serialized.
    if (info.kind == 'attribute') {
        this.serializeValueToAttribute(value, property, node);
    } else {
        // TODO(sorvell): consider pre-processing this step so we don't need
        // this lookup.
        if (property === 'className') {
          value = this._scopeElementClass(node, value);
        }
        return node[property] = value;
    }
}

At the end of this method return node[property] = value; causes the input's value to be overwritten with the same value which moves the caret to the end.

Can we maybe change it to the following?

if(node[property] !== value)
    node[property] = value;

return value;
@kevinpschaaf
Copy link
Member

Fixed in 275c41a.

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

No branches or pull requests

2 participants