gatanaso/multiselect-combo-box-flow

Javascript Uncaught TypeError: Cannot read property 'comboBox' of undefined at Object.initLazy (multiselectComboBoxConnector.js?ec3f:33)

urkl opened this issue · 9 comments

urkl commented

Hi Goran.
Again thanks for great addon.

I find out that on page refresh I get some strange javascript errors.

8634D9D71A7734952088B7D2A08EB3DE.cache.js:980 Exception is thrown during JavaScript execution. Stacktrace will be dumped separately. tt @ client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:980 client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:195 (TypeError) : $0.$connector.confirm is not a function KB @ client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:195 client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:54 Uncaught TypeError: Cannot read property 'comboBox' of undefined at Object.initLazy (multiselectComboBoxConnector.js?ec3f:33) at HTMLElement.eval (eval at tt (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:980), <anonymous>:3:70) at Object.eval (eval at tt (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:980), <anonymous>:3:87) at tt (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:980) at st (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:937) at qt (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:562) at Yq (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:479) at ur.vr [as W] (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988) at oA (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:870) at zv (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:981) at hx.ix [as J] (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988) at Function.Dl (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988) at d (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:638) at Set.forEach (<anonymous>) at gl (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:754) at HTMLElement.s.ready (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:988) at HTMLElement._enableProperties (properties-changed.js?2b39:333) at HTMLElement.connectedCallback (properties-mixin.js?2f2d:214) at HTMLElement.connectedCallback (element-mixin.js?301f:619) at xv (client-8634D9D71A7734952088B7D2A08EB3DE.cache.js:944)

Hi @urkl

Thank you for reporting this issue. It looks like the component hasn't been initialized properly after doing a page refresh. Would it be possible that you provide a minimal reproducible example that I could look into more closely?

urkl commented

Hi Goran.

Here you go. https://gitlab.com/uros.kristan/multi-select-field-test

I found out that the problem occurs in conjunction with app-layout addon.

To reproduce the problem please follow this steps:

  • run project
  • click on Multi Select in menu
  • select some items
  • refresh browser window

And another question: Would it be possible to implement onItemClickListener for selected items. Not on x sign to remove them, but directly on item?

Hi @urkl

Thank you for providing the project, I will have a look at the issue.

Regarding the onItemClickListener, I think it would be possible to add such functionality.

I think the issue happens because the initLazy() method of the connector is executed before the ready() method of the component. Therefore, the component is not yet initialized and these errors occur.

Found a similar issue here: https://github.com/vaadin/vaadin-grid-flow/issues/586

urkl commented

This is not good news if I understand this correctly. Bug from Vaadin is from March.

Yes, unfortunately there has not been a lot of activity on that ticket.
Have you tried using the MultiselectComboBox in an app without the app layout add-on?
From what I have briefly tested, when used without the app layout add-on there are no issues at all as the initialization order is preserved.

urkl commented

Do you know for a way to override this annoying bug ?
Bug happens when opening in new browser window.

Hi @urkl

I have been able to workaround this issue by modifying the connector code to execute once the element is defined. There is a new version available that includes this fix 2.2.1.rc1.

Could you please test with this version and let me know if it fixes the issue:

<dependency>
   <groupId>org.vaadin.gatanaso</groupId>
   <artifactId>multiselect-combo-box-flow</artifactId>
   <version>2.2.1.rc1</version>
</dependency>

BR,
Goran

urkl commented

Goran! It works. Thank you!
I think that you even fixed issue posted on vaadin directory by Muhammad Faisal.

Best Regards, Uroš!