eakoriakin / ionic-selectable

Ionic Selectable is an Ionic versatile and highly customizable component that serves as a replacement to Ionic Select, and allows to search items, including async search, create items, customize the layout with templates and much more. It provides an intuitive API and is easy to set up and use.
MIT License
550 stars 123 forks source link

Undefined properties. Problems with 'selectableComponent' variable #409

Open Sebastian-Elstadt opened 1 year ago

Sebastian-Elstadt commented 1 year ago

I am running an Ionic 6 Capacitor(v4.6.2) app. It has "@ionic-selectable/angular": "^5.0.0-alpha.19" installed. The module is imported in my app component and the child component. (I am using the new Angular standalone: true methods for my components.) The ionic-selectable component loads correctly in the ion-item. But once it is opened, the console is bombarded with:

Cannot read properties of undefined (reading 'selectableComponent') Cannot read properties of undefined (reading 'isAddItemTemplateVisible') Cannot read properties of undefined (reading 'shouldFocusSearchbar') Cannot read properties of undefined (reading 'selectableComponent')

The first error seems to stem from a method called connectedCallback, which looks like the following:

const modalElement = document.querySelector('ion-modal'); this.selectableComponent = modalElement.componentProps.selectableComponent; this.selectableComponent.selectableModalComponent = this;

And it looks like componentProps is undefined, causing the error, and keeping selectableComponent null/undefined which crashes other code.

schagani commented 1 year ago

Hi, I am facing the same issue. It works find on the page but not working in the modal. Regards