Skip to content

Commit

Permalink
Merge pull request #4805 from nextcloud-libraries/fix/align-default-l…
Browse files Browse the repository at this point in the history
…abel-with-icon
  • Loading branch information
raimund-schluessler authored Nov 12, 2023
2 parents ae35ed8 + 118d82c commit af6c72c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions l10n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ msgstr ""
msgid "Related resources"
msgstr ""

msgid "Save changes"
msgstr ""

msgid "Search"
msgstr ""

Expand Down
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

0 comments on commit af6c72c

Please sign in to comment.