formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

Select / SetValue / TriggerUpdate with only string parameters #5502

Open ssabw1 opened 9 months ago

ssabw1 commented 9 months ago

https://github.com/formio/formio.js/blob/832f6cab28d6ea4ef6feda5bffd69a4784eb6b6e/src/components/select/Select.js#L1522

We have a case that this function takes the next parameters: this.triggerUpdate(_.get(undefined || 'Cardiff', 'search', 'Cardiff'), true);

In this case we get an empty function like function search() { [native code] } and this causes to throw an error.

Maybe need to check this case like:

        var defaultValue = value;
        value = !value.data && typeof value === 'string' && typeof searchProperty === 'string' && !!searchProperty.length ? {[searchProperty]: value} : value;
        this.triggerUpdate(_.get(value.data || value, searchProperty, defaultValue), true);

Or maybe have another solution?

Thanks a lot.

brendanbond commented 2 months ago

I'm not sure I completely understand - can you provide us with a JSFiddle or something similar so we can better grok your use case here?