baoagency / polaris_view_components

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

Polaris::SelectComponent not updating when using turbo #433

Open alhafoudh opened 1 month ago

alhafoudh commented 1 month 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 1 month 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?