fix: default labels with SettingDropdown and SelectDropdown (#3854)

* Remove modification to label in SelectDropdown
* Only set 'defaultLabel' if falsy and translate "Custom" default
This commit is contained in:
David Sevilla Martin 2023-07-27 06:24:19 -04:00 committed by GitHub
parent c80220ad9b
commit da1aa2aa92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 5 deletions

View File

@ -21,7 +21,7 @@ export default class SettingDropdown<CustomAttrs extends ISettingDropdownAttrs =
attrs.className = 'SettingDropdown';
attrs.buttonClassName = 'Button Button--text';
attrs.caretIcon = 'fas fa-caret-down';
attrs.defaultLabel = 'Custom';
attrs.defaultLabel ||= app.translator.trans('core.admin.settings.select_dropdown_custom_label');
if ('key' in attrs) {
attrs.setting = attrs.key?.toString();

View File

@ -28,7 +28,7 @@ function isActive(vnode: Mithril.Children): boolean {
}
export interface ISelectDropdownAttrs extends IDropdownAttrs {
defaultLabel: string;
defaultLabel: Mithril.Children;
}
/**
@ -49,9 +49,6 @@ export default class SelectDropdown<CustomAttrs extends ISelectDropdownAttrs = I
const activeChild = children.find(isActive);
let label = (activeChild && typeof activeChild === 'object' && 'children' in activeChild && activeChild.children) || this.attrs.defaultLabel;
// @ts-ignore
if (Array.isArray(label)) label = label[0];
return [<span className="Button-label">{label}</span>, this.attrs.caretIcon ? icon(this.attrs.caretIcon, { className: 'Button-caret' }) : null];
}
}

View File

@ -252,6 +252,7 @@ core:
# These translations are used generically in setting fields.
settings:
saved_message: Your changes were saved.
select_dropdown_custom_label: Custom
submit_button: => core.ref.save_changes
# These translations are used in image upload buttons.