mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
common: fix listItems marking all items as active
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import Button, {ButtonProps} from './Button';
|
import Button, {ButtonProps} from './Button';
|
||||||
|
|
||||||
interface LinkButtonProps extends ButtonProps {
|
interface LinkButtonProps extends ButtonProps {
|
||||||
active: string;
|
active: boolean;
|
||||||
oncreate: Function;
|
oncreate: Function;
|
||||||
href?: string;
|
href?: string;
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@ export default class LinkButton extends Button<LinkButtonProps> {
|
|||||||
const vdom = super.view();
|
const vdom = super.view();
|
||||||
|
|
||||||
vdom.tag = m.route.Link;
|
vdom.tag = m.route.Link;
|
||||||
|
vdom.attrs.active = String(vdom.attrs.active);
|
||||||
|
|
||||||
return vdom;
|
return vdom;
|
||||||
}
|
}
|
||||||
@@ -34,11 +35,9 @@ export default class LinkButton extends Button<LinkButtonProps> {
|
|||||||
/**
|
/**
|
||||||
* Determine whether a component with the given props is 'active'.
|
* Determine whether a component with the given props is 'active'.
|
||||||
*/
|
*/
|
||||||
static isActive(props: LinkButtonProps): string {
|
static isActive(props: LinkButtonProps): boolean {
|
||||||
return String(
|
return typeof props.active !== 'undefined'
|
||||||
typeof props.active !== 'undefined'
|
|
||||||
? props.active
|
? props.active
|
||||||
: m.route.get() === props.href
|
: m.route.get() === props.href;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,10 +41,9 @@ export default function listItems(items) {
|
|||||||
|
|
||||||
const node = isListItem
|
const node = isListItem
|
||||||
? item
|
? item
|
||||||
: <li className={classNames([
|
: <li className={classNames(className, [
|
||||||
(item.itemName ? 'item-' + item.itemName : ''),
|
(item.itemName && `item-${item.itemName}`),
|
||||||
className,
|
active && 'active',
|
||||||
(active ? 'active' : '')
|
|
||||||
])}
|
])}
|
||||||
key={item.attrs?.key || item.itemName}>
|
key={item.attrs?.key || item.itemName}>
|
||||||
{item}
|
{item}
|
||||||
|
@@ -51,14 +51,14 @@ export default class SessionDropdown extends Dropdown {
|
|||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
// items.add('settings',
|
items.add('settings',
|
||||||
// LinkButton.component({
|
LinkButton.component({
|
||||||
// icon: 'fas fa-cog',
|
icon: 'fas fa-cog',
|
||||||
// children: app.translator.trans('core.forum.header.settings_button'),
|
children: app.translator.trans('core.forum.header.settings_button'),
|
||||||
// href: app.route('settings')
|
href: app.route('settings')
|
||||||
// }),
|
}),
|
||||||
// 50
|
50
|
||||||
// );
|
);
|
||||||
|
|
||||||
if (app.forum.attribute('adminUrl')) {
|
if (app.forum.attribute('adminUrl')) {
|
||||||
items.add('administration',
|
items.add('administration',
|
||||||
@@ -67,7 +67,6 @@ export default class SessionDropdown extends Dropdown {
|
|||||||
children: app.translator.trans('core.forum.header.admin_button'),
|
children: app.translator.trans('core.forum.header.admin_button'),
|
||||||
href: app.forum.attribute('adminUrl'),
|
href: app.forum.attribute('adminUrl'),
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
config: () => {}
|
|
||||||
}),
|
}),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user