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 input: list of options retaining old values when data updates #52

Closed
gwvt opened this issue May 3, 2017 · 1 comment
Closed
Labels

Comments

@gwvt
Copy link
Contributor

gwvt commented May 3, 2017

I have a select input with a list of options that gets updated based on another user input, like this:

template:

<!-- selectA -->
<b-select v-model="selectArray" @change="changeArray1()">
  <b-option v-for="i in [0, 1, 2]" :value="i"
  :key="i">
    {{ i }}
  </b-option>
</b-select>

<!-- selectB -->
<b-select>
  <b-option v-for="item in array1" :value="item"
  :key="item">
    {{ item }}
  </b-option>
</b-select>

script:

data() {
  return {
    array1: [1, 2, 3],
    selectArray: 0,
  };
},
methods: {
  changeArray1() {
    const arrays = [[1, 2, 3], [2, 3, 4], [4, 5, 6]];
    this.array1 = arrays[this.selectArray];
  },
},

As you can see, the user changing the input in selectA changes the values held in array1. Some of these values are the same, some different. Instead of the options for selectB being cleanly updated to bind to the new values held in array1, the list of selectB options retains the original values held in array1 and appends the values held in the new array1. I haven't determined the logic, but on multiple user inputs in the selectA to reassign values to array1, sometimes the duplicate values are appended to the end of the list of options for selectB and sometimes not.

One solution I explored was forcing the DOM to re-render, but after trying many things I was not able to get that to work.

Am I missing something? How can I get the select list to update cleanly?

@rafaberaldo rafaberaldo added the bug label May 3, 2017
@rafaberaldo
Copy link
Member

rafaberaldo commented May 3, 2017

I'm probably just gonna replace bOption with the native option, LMFT

rafaberaldo added a commit that referenced this issue May 3, 2017
rafaberaldo added a commit that referenced this issue May 5, 2017
kikuomax added a commit to kikuomax/buefy that referenced this issue Sep 4, 2023
* test(lib): update Button spec

- Updates the unit tests (spec) of `Button` so that they can work with
  `@vue/test-utils` V2.
    - Replaces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in V2.
    - Replaces the test of `wrapper.isVueInstance()` with that of
      presence of `wrapper.vm` because `wrapper.isVueInstance` no longer
      exists in V2.
    - Replaces `listeners.click` in the options for `shallowMount` with
      `props.onClick` because the interface of the options has changed
      in V2.
    - Replaces `wrapper.contains` with a combination of `wrapper.find`
      and `exists` because `wrapper.contains` no longer exists in V2.
    - Awaits `wrapper.setProps` to make sure new properties are applied
      before testing subsequent assertions.
    - Updates the snapshot. I did not see any problem with the new
      snapshot.

issue ntohq#1

* chore(lib): remove comment on Button.spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants