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

[MdTable] emitting @md-selected with no value #1559

Closed
emman27 opened this issue Feb 27, 2018 · 2 comments · Fixed by #1585
Closed

[MdTable] emitting @md-selected with no value #1559

emman27 opened this issue Feb 27, 2018 · 2 comments · Fixed by #1585
Labels

Comments

@emman27
Copy link
Contributor

emman27 commented Feb 27, 2018

Steps to reproduce

Using vue-material@1.0.0-beta-8, with the following code.

<template>
  <div>
    <md-table md-card v-model="lists" v-if="lists.length !== 0"  @md-selected="onSelect">
      <md-table-row slot="md-table-row" slot-scope="{ item }" md-selectable="single">
        <md-table-cell md-label="Name">{{ item.name }}</md-table-cell>
      </md-table-row>
    </md-table>
  </div>
</template>

<script>
import getLists from '@/api';

export default {
  data() {
    return {
      lists: [],
    };
  },
  async created() {
    try {
      this.lists = await getLists();
    } catch (err) {
      console.log(err)
    }
  },
  methods: {
    onSelect(item) {
      console.log(item);
    },
  },
};
</script>

Which browser?

Multiple (Chrome 64, Firefox)

What is expected & What is actually happening?

onSelect should only be called when something is clicked. However, it is being called every time the component appears (not sure created or mounted, tbh), and called with undefined.

@Samuell1
Copy link
Member

Samuell1 commented Mar 4, 2018

If you try without v-if="lists.length !== 0" its happening too?

@emman27
Copy link
Contributor Author

emman27 commented Mar 6, 2018

Yeah it's still happening.

@Samuell1 Samuell1 added the bug label Mar 6, 2018
marcosmoura pushed a commit that referenced this issue Mar 7, 2018
…lly changed (#1585)

* fix(MdTable): only emit selected / update event when selected item(s) really changed

fix #1559

* refactor(MdTable): selectedItems check changed beautify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants