Skip to content

Commit

Permalink
Prevent "Uncaught TypeError: n.context[i.value][u] is undefined" when…
Browse files Browse the repository at this point in the history
… adding external WMS Layer (#583)

* Fix check indexItem for select2 directive

* reduce delta

---------

Co-authored-by: Raruto <[email protected]>
  • Loading branch information
volterra79 and Raruto authored Feb 26, 2024
1 parent 8a85e56 commit 66efef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/WMSLayersPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</label>
<select
id = "g3w-wms-layers"
multiple = "multiple"
:multiple = "true"
clear = "true"
v-select2 = "'selectedlayers'"
>
Expand Down
6 changes: 5 additions & 1 deletion src/directives/v-select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default {
select2_value,
indexItem, /** @since 3.9.1 */
} = vnode.data.attrs || {};
const isArray = binding.value && Array.isArray(vnode.context[binding.value]); //check if is an array
const isArray = binding.value
&& Array.isArray(vnode.context[binding.value]) // check if is an array
&& undefined !== indexItem // check if indexItem is defined
$(el)
.select2({
width: '100%',
Expand All @@ -24,7 +26,9 @@ export default {
})
.on('select2:select', (e) => {
if (binding.value) {
//get value
const value = e.params.data.id;
//check is can have multiple value
if (multiple && (
(isArray
? vnode.context[binding.value][indexItem].value
Expand Down

0 comments on commit 66efef7

Please sign in to comment.