mirror of
https://github.com/flarum/core.git
synced 2025-08-01 06:00:24 +02:00
fix: empty string displayed as SelectDropdown title (#3773)
* fix: empty string displayed as SelectDropdown title * chore: remove import * chore: ts-ignore * Update framework/core/js/src/common/components/SelectDropdown.tsx Co-authored-by: David Wheatley <david@davwheat.dev> --------- Co-authored-by: David Wheatley <david@davwheat.dev>
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import Dropdown, { IDropdownAttrs } from './Dropdown';
|
import Dropdown, { IDropdownAttrs } from './Dropdown';
|
||||||
import icon from '../helpers/icon';
|
import icon from '../helpers/icon';
|
||||||
import extractText from '../utils/extractText';
|
|
||||||
import classList from '../utils/classList';
|
import classList from '../utils/classList';
|
||||||
import type Component from '../Component';
|
import type Component from '../Component';
|
||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
@@ -50,7 +49,8 @@ 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;
|
||||||
|
|
||||||
label = extractText(label);
|
// @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];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user