Skip to content

Commit

Permalink
fix(NcActionButton): Add some more documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 23, 2024
1 parent 9e15e67 commit 00b1c74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/NcActionButton/NcActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ export default {

/**
* The buttons state if `type` is 'checkbox' or 'radio' (meaning if it is pressed / selected)
* Either boolean for checkbox and toggle button behavior or `value` for radio behavior
* Either boolean for checkbox and toggle button behavior or `value` for radio behavior.
*
* **This is not availabe for `type='submit'` or `type='reset'`**
*
* If using `type='checkbox'` a `model-value` of `true` means checked, `false` means unchecked and `null` means indeterminate (tri-state)
* For `type='radio'` `null` is equal to `false`
*/
modelValue: {
type: [Boolean, String],
Expand Down Expand Up @@ -457,12 +462,12 @@ export default {
if (this.type === 'radio') {
attributes.role = 'menuitemradio'
attributes['aria-checked'] = this.isChecked ? 'true' : 'false'
} else if (this.type === 'checkbox' || this.modelValue !== null) {
} else if (this.type === 'checkbox' || (this.nativeType === 'button' && this.modelValue !== null)) {
// either if checkbox behavior was set or the model value is not unset
attributes.role = 'menuitemcheckbox'
attributes['aria-checked'] = this.modelValue === null ? 'mixed' : (this.modelValue ? 'true' : 'false')
}
} else if (this.modelValue !== null) {
} else if (this.modelValue !== null && this.nativeType === 'button') {
// In case this has a modelValue it is considered a toggle button, so we need to set the aria-pressed
attributes['aria-pressed'] = this.modelValue ? 'true' : 'false'
}
Expand Down

0 comments on commit 00b1c74

Please sign in to comment.