baoagency / polaris_view_components

ViewComponents for Polaris Design System
https://polarisviewcomponents.org
MIT License
388 stars 55 forks source link

Polaris::SelectComponent not updating when using turbo #433

Open alhafoudh opened 4 months ago

alhafoudh commented 4 months ago

When page content is updated via turbo, Polaris::SelectComponent is not updating it's selectedOption target's innerText. The selectedOption target's innerText is updated only on connect() or change.

Here: https://github.com/baoagency/polaris_view_components/blob/main/app/assets/javascripts/polaris_view_components/select_controller.js#L3

alhafoudh commented 4 months ago

I found a hot-fix for this. I add ... , input_options: { data: { action: 'turbo:load@window->polaris-select#update' } } to the Polaris::SelectComponent.

Should this behavior be in this library or we should leave it to the developer to handle this case?

wntechs commented 2 months ago

I found a hot-fix for this. I add ... , input_options: { data: { action: 'turbo:load@window->polaris-select#update' } } to the Polaris::SelectComponent.

Should this behavior be in this library or we should leave it to the developer to handle this case?

I also face the similar issue. Not sure why it is not taken care of yet. @alhafoudh Can you please provide more details about your hot-fix how you resolved this? Thanks

wntechs commented 2 months ago

I found a hot-fix for this. I add ... , input_options: { data: { action: 'turbo:load@window->polaris-select#update' } } to the Polaris::SelectComponent. Should this behavior be in this library or we should leave it to the developer to handle this case?

I also face the similar issue. Not sure why it is not taken care of yet. @alhafoudh Can you please provide more details about your hot-fix how you resolved this? Thanks

I was missing the npm package integration, after I install the related package the issue is resolved.