baoagency / polaris_view_components

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

Refactor button disabling with Stimulus value attribute #440

Closed kirillplatonov closed 3 months ago

kirillplatonov commented 3 months ago

Value attributes are more reliable when button state changed by external Stimulus controller.

hoppergee commented 2 months ago

Hi @kirillplatonov

I came from the v2.2.2 release note and found the functionality of the disable/enable function seems to have become a purely UI change after this PR. Does this mean that users need to manually change the button's disabled state, rather than continuing to rely on the function in the button controller after this release?

kirillplatonov commented 2 months ago

The functionality should be the same. When the button is disabled we ignoring future clicks until it's enabled again: https://github.com/baoagency/polaris_view_components/blob/main/app/assets/javascripts/polaris_view_components/button_controller.js#L8

I updated preview for this feature to better demonstrate how it works. If it's not working for you then it's probably a bug. https://polarisviewcomponents.org/lookbook/inspect/button/disable_with_actions

Changes in this PR must only improve the internal implementation to better work with external controller (eg when button state is managed by form controller and synchronized with App Bridge save bar).