mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
update/fix: forum/components/SplitDropdown
This commit is contained in:
committed by
Franz Liedke
parent
f44caf1600
commit
ddb0a9f1ce
@@ -14,18 +14,18 @@ export default class SplitDropdown extends Dropdown {
|
|||||||
attrs.menuClassName += ' Dropdown-menu--right';
|
attrs.menuClassName += ' Dropdown-menu--right';
|
||||||
}
|
}
|
||||||
|
|
||||||
getButton() {
|
getButton(children) {
|
||||||
// Make a copy of the props of the first child component. We will assign
|
// Make a copy of the attrs of the first child component. We will assign
|
||||||
// these props to a new button, so that it has exactly the same behaviour as
|
// these attrs to a new button, so that it has exactly the same behaviour as
|
||||||
// the first child.
|
// the first child.
|
||||||
const firstChild = this.getFirstChild();
|
const firstChild = this.getFirstChild(children);
|
||||||
const buttonProps = Object.assign({}, firstChild.props);
|
const buttonAttrs = Object.assign({}, firstChild.attrs);
|
||||||
buttonProps.className = (buttonProps.className || '') + ' SplitDropdown-button Button ' + this.props.buttonClassName;
|
buttonAttrs.className = (buttonAttrs.className || '') + ' SplitDropdown-button Button ' + this.attrs.buttonClassName;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Button.component(buttonProps),
|
Button.component(buttonAttrs, firstChild.children),
|
||||||
<button className={'Dropdown-toggle Button Button--icon ' + this.props.buttonClassName} data-toggle="dropdown">
|
<button className={'Dropdown-toggle Button Button--icon ' + this.attrs.buttonClassName} data-toggle="dropdown">
|
||||||
{icon(this.props.icon, { className: 'Button-icon' })}
|
{icon(this.attrs.icon, { className: 'Button-icon' })}
|
||||||
{icon('fas fa-caret-down', { className: 'Button-caret' })}
|
{icon('fas fa-caret-down', { className: 'Button-caret' })}
|
||||||
</button>,
|
</button>,
|
||||||
];
|
];
|
||||||
@@ -38,8 +38,8 @@ export default class SplitDropdown extends Dropdown {
|
|||||||
* @return {*}
|
* @return {*}
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
getFirstChild() {
|
getFirstChild(children) {
|
||||||
let firstChild = this.props.children;
|
let firstChild = children;
|
||||||
|
|
||||||
while (firstChild instanceof Array) firstChild = firstChild[0];
|
while (firstChild instanceof Array) firstChild = firstChild[0];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user