Lundalogik / lime-elements

Provides reusable web components for Lime CRM
https://lundalogik.github.io/lime-elements/versions/latest
Other
38 stars 11 forks source link

Fix disabled trailing icon remains disabled until input field changes #2973

Closed vicgeralds closed 4 months ago

vicgeralds commented 4 months ago

Makes sure the mdc textfield disabled state is updated correctly. This required changing how the invalid icon is rendered as well.

Rendering an input field as disabled with a trailing icon and later setting disabled={false} did not work for some reason. When initializing MDCTextField, it will disable the trailing icon by setting tabindex="-1" which makes it unclickable. The problem can be seen here:

https://github.com/Lundalogik/lime-elements/assets/5563232/fd3efad7-2c38-49d8-b9a1-55796f756cd0

It is possible to reproduce by changing the date picker composite example, adding disabled: true to the initial state props and removing key={`updateOnFormChange-${this.key}`} when rendering <limel-date-picker>.

When updating the disabled state, the initial invalid state of the input field also matters. Since MDCTextField expects the trailing icon to be a button that should be clickable when the input field is not disabled, rendering the invalid icon with class mdc-text-field__icon--trailing causes unwanted behaviour. If the input field is initially invalid, the saved tabstate for the trailing icon will be -1, and it will stay unclickable when enabling the input field.

Review:

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

Linux:

macOS:

Mobile:

github-actions[bot] commented 4 months ago

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-2973/

lime-opensource commented 4 months ago

:tada: This PR is included in version 37.33.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: