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

[select] Setting value to "0" (number) does not work #1011

Closed
4 tasks done
tomalec opened this issue Jun 7, 2018 · 2 comments
Closed
4 tasks done

[select] Setting value to "0" (number) does not work #1011

tomalec opened this issue Jun 7, 2018 · 2 comments

Comments

@tomalec
Copy link
Contributor

tomalec commented Jun 7, 2018

Description

Live Demo

https://jsbin.com/cemagub/edit?html,output

Steps to Reproduce

  1. Create vaadin-dropdown-menu with numeric values,
  2. Pick the first (0-indexed) element or try to preset it with value="0"
<dom-bind id="db">
  <template>
    <vaadin-dropdown-menu label="Label" placeholder="Placeholder" value="{{model.selectedItem}}">
    <!-- same goes for 
      <vaadin-dropdown-menu label="Label" placeholder="Placeholder" value="0">
    -->
      <template>
        <vaadin-list-box>
          <template is="dom-repeat" items="{{model.items}}">
            <vaadin-item value="{{index}}">{{item}}</vaadin-item>
          </template>
          <hr>
          <vaadin-item disabled>Option four</vaadin-item>
        </vaadin-list-box>
      </template>
    </vaadin-dropdown-menu>
  </template>
</dom-bind>
<script>
  db.set('model', {items: ["zero", "one", "two"], selectedItem: 0});
</script>

Expected Results

The first element should be selected

Actual Results

Dropdown behaves as there is nothing selected

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • [?] Safari 9
  • [?] Safari 8
  • IE 11

Versions

@web-padawan
Copy link
Member

web-padawan commented Aug 1, 2018

The problem gets fixed if you use string value. See the glitch with the working example:

https://glitch.com/edit/#!/caramel-rise?path=index.html:14:74

Basically, you should use value$ attribute bindings for both items and dropdown-menu itself to make sure the values are passed as strings. We probably have to document it better, or warn about numeric value usage to not confuse developers.

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-select May 19, 2021
@web-padawan web-padawan changed the title Setting value to "0" does not work [select] Setting value to "0" (number) does not work May 20, 2021
@web-padawan
Copy link
Member

This is now fixed by #4064 and released in Vaadin 23.1.2 and later. Closing.

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

No branches or pull requests

3 participants