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

filterByFormatted won't work when using field key not in data object #5672

Closed
bobvandevijver opened this issue Aug 20, 2020 · 1 comment · Fixed by #5674
Closed

filterByFormatted won't work when using field key not in data object #5672

bobvandevijver opened this issue Aug 20, 2020 · 1 comment · Fixed by #5674

Comments

@bobvandevijver
Copy link

Describe the bug

When you specify a key in the field definition which does not exist in your data object, the filterByFormatted option doesn't work. I used a dedicated key to create a new field with a formatter that combines three other fields which are not shown in the table.

Steps to reproduce the bug

Use the following template:

<template>
  <div>
    <b-input v-model="filter"></b-input>
    <b-table :fields="fields" :items="items" :filter="filter"></b-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        filter: null,
        items: [{
          col1: 'Item',
          col2: 'Something',
        }],
        fields: [{
          key: 'col1',
        }, {
          key: 'col2',
          formatter: () => 'Foo',
          filterByFormatted: true,
        }, {
          key: 'col3',
          formatter: () => 'Bar',
          filterByFormatted: true,
        }]
      }
    },
  }
</script>

Or open https://codesandbox.io/s/jccv2?file=/App.vue.

Search on Foo -> Item is still visible
Search on Bar -> Item is no longer visible

Expected behavior

b-table should respect the new field when filterByFormatted is set for it.

Versions

Libraries:

  • BootstrapVue: 2.16.0
  • Bootstrap: 4.5.0
  • Vue: 2.6.11

Environment:

  • Device: Laptop
  • OS: Windows 10
  • Browser: Edge
  • Version: 84.0.522.61

Demo link

See https://codesandbox.io/s/jccv2?file=/App.vue

@jacobmllr95 jacobmllr95 self-assigned this Aug 20, 2020
jacobmllr95 added a commit that referenced this issue Aug 20, 2020
closes #5672) (#5674)

* fix(b-table): make sure to apply all formatters of field configuration

* Update .bundlewatch.config.json

* Update .bundlewatch.config.json

* Update table-filtering.spec.js
@bobvandevijver
Copy link
Author

Wauw, awesome and fast work @jackmu95 😃

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