Skip to content

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

Description

@Sleeckx

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;

Activity

  1. added a commit that references this issue on May 6, 2015
    275c41a
  2. kevinpschaaf commented on May 6, 2015

    @kevinpschaaf
    Member

    Fixed in 275c41a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions