mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 15:33:20 +08:00
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:
parent
c80220ad9b
commit
da1aa2aa92
|
@ -21,7 +21,7 @@ export default class SettingDropdown<CustomAttrs extends ISettingDropdownAttrs =
|
||||||
attrs.className = 'SettingDropdown';
|
attrs.className = 'SettingDropdown';
|
||||||
attrs.buttonClassName = 'Button Button--text';
|
attrs.buttonClassName = 'Button Button--text';
|
||||||
attrs.caretIcon = 'fas fa-caret-down';
|
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) {
|
if ('key' in attrs) {
|
||||||
attrs.setting = attrs.key?.toString();
|
attrs.setting = attrs.key?.toString();
|
||||||
|
|
|
@ -28,7 +28,7 @@ function isActive(vnode: Mithril.Children): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISelectDropdownAttrs extends IDropdownAttrs {
|
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);
|
const activeChild = children.find(isActive);
|
||||||
let label = (activeChild && typeof activeChild === 'object' && 'children' in activeChild && activeChild.children) || this.attrs.defaultLabel;
|
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];
|
return [<span className="Button-label">{label}</span>, this.attrs.caretIcon ? icon(this.attrs.caretIcon, { className: 'Button-caret' }) : null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,7 @@ core:
|
||||||
# These translations are used generically in setting fields.
|
# These translations are used generically in setting fields.
|
||||||
settings:
|
settings:
|
||||||
saved_message: Your changes were saved.
|
saved_message: Your changes were saved.
|
||||||
|
select_dropdown_custom_label: Custom
|
||||||
submit_button: => core.ref.save_changes
|
submit_button: => core.ref.save_changes
|
||||||
|
|
||||||
# These translations are used in image upload buttons.
|
# These translations are used in image upload buttons.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user