Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcTextField): Align default label for trailing button with used icon #4805

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/NcTextField/NcTextField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ export default {
// Reuse all the props from NcInputField for better typing and documentation
...NcInputField.props,

// Redefined props

/**
* Label of the trailing button
* The `aria-label` to set on the trailing button
* If no explicit value is set it will default to the one matching the `trailingButtonIcon`:
* @default 'Clear text'|'Save changes'|'Undo changes'
*/
trailingButtonLabel: {
type: String,
default: t('Clear text'),
default: '',
},

// Custom props
Expand All @@ -216,13 +216,21 @@ export default {

computed: {
propsAndAttrsToForward() {
const predefinedLabels = {
undo: t('Undo changes'),
close: t('Clear text'),
arrowRight: t('Save changes'),
}

return {
// Proxy all the HTML attributes
...this.$attrs,
// Proxy original NcInputField's props
...Object.fromEntries(
Object.entries(this.$props).filter(([key]) => NcInputFieldProps.has(key)),
),
// Adjust aria-label for predefined trailing buttons
trailingButtonLabel: this.trailingButtonLabel || predefinedLabels[this.trailingButtonIcon],
}
},
},
Expand Down
Loading