Reactivesearch: Setting sortOptions prop raises "Cannot read property 'dataField' of undefined"

Created on 9 Jun 2020  路  4Comments  路  Source: appbaseio/reactivesearch

Affected Projects
Vue.JS

Library Version:
>= v1.3.0

Describe the bug

Setting the sortOptions prop in a ReactiveList raises an error and the ReactiveList is not displayed:

vue.runtime.esm.js:1888 TypeError: Cannot read property 'dataField' of undefined
    at VueComponent.mounted (reactivesearch-vue.es.js:1441)
    at invokeWithErrorHandling (vue.runtime.esm.js:1854)
    at callHook (vue.runtime.esm.js:4219)
    at Object.insert (vue.runtime.esm.js:3139)
    at invokeInsertHook (vue.runtime.esm.js:6346)
    at VueComponent.patch [as __patch__] (vue.runtime.esm.js:6565)
    at VueComponent.Vue._update (vue.runtime.esm.js:3948)
    at VueComponent.updateComponent (vue.runtime.esm.js:4066)
    at Watcher.get (vue.runtime.esm.js:4479)
    at Watcher.run (vue.runtime.esm.js:4554)

It seems to me, that this stems from a property introduced in v1.3.0:
https://github.com/appbaseio/reactivesearch/commit/de4d7d562a52fd03f51d29a23b339166ba3fa748#diff-56b460a307f33988399b5130e4cf2d8aR308
The selection of the sort option prior to v1.3.0 was hard coded to the first list element.

I am not very well versed in Vue.js or React but I looked through the repository and I could not find
this.sortOptionIndex anywhere else in the Vue.js project. It does not seem to be defined anywhere.
I could find it in the React part of the project where it is defined through a ReactiveList prop
called defaultSortOption:

https://github.com/appbaseio/reactivesearch/search?q=defaultSortOption&unscoped_q=defaultSortOption

Which I also could not find. Neither in the code nor in the documentation for the Vue.js Project.
I have tried to set the prop but it did not solve the problem.

To Reproduce

Steps to reproduce the behavior:

Set the sortOptions prop for a reactive-list in >=v1.3.0
Sandbox: https://codesandbox.io/s/empty-wildflower-427pu?file=/src/App.vue

In the sandbox Error in mounted hook: "TypeError: this.$props.sortOptions[this.sortOptionIndex] is undefined" is raised.

Expected behavior

I would expect the defaultSortOption to be configurable or the this.sortOptionIndex property to default to 0. And for the ReactiveList to be displayed when the sortOptions prop is set.
Or if the defaultSortOption prop is read through something that I missed, I would expect the
documentation to list the defaultSortOption prop and explain its usage.

Desktop:

  • OS: Ubuntu 20.04
  • Browser Chrome
  • Version 81.0.4044.138
bug

Most helpful comment

Fixed in 1.5.0

All 4 comments

Same error pops up when I try to add aggregationField="_id" property to the reactive list. Though I believe it is something in helper.js.

Same issue, seems like this.sortOptionIndex is undefined.

Fixed in 1.5.0

Great, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tiagogm picture tiagogm  路  3Comments

felubra picture felubra  路  3Comments

mrtinkz picture mrtinkz  路  3Comments

willopez picture willopez  路  3Comments

vharitonsky picture vharitonsky  路  4Comments