mirror of
https://github.com/flarum/framework.git
synced 2025-04-13 22:32:25 +08:00
Key item lists to maintain identity across redraws
Fixes #667. This issue was due to the fact that Mithril would change the "Lock" badge into a "Sticky" badge, but the tooltip initialization would not be triggered because it was using the same element. By maintaining element identity, the "Lock" badge will remain untouched, and a new element for the "Sticky" badge will be inserted before it. See https://lhorie.github.io/mithril/mithril.html#dealing-with-focus for more information.
This commit is contained in:
parent
df2a199b48
commit
e5a7013c2c
@ -24,11 +24,6 @@ export default class Badge extends Component {
|
||||
attrs.className = 'Badge ' + (type ? 'Badge--' + type : '') + ' ' + (attrs.className || '');
|
||||
attrs.title = extract(attrs, 'label') || '';
|
||||
|
||||
// Give the badge a unique key so that when badges are displayed together,
|
||||
// and then one is added/removed, Mithril will correctly redraw the series
|
||||
// of badges.
|
||||
attrs.key = attrs.type;
|
||||
|
||||
return (
|
||||
<span {...attrs}>
|
||||
{iconName ? icon(iconName, {className: 'Badge-icon'}) : m.trust(' ')}
|
||||
|
@ -41,7 +41,8 @@ export default function listItems(items) {
|
||||
(item.itemName ? 'item-' + item.itemName : ''),
|
||||
className,
|
||||
(active ? 'active' : '')
|
||||
])}>
|
||||
])}
|
||||
key={item.itemName}>
|
||||
{item}
|
||||
</li>,
|
||||
' '
|
||||
|
Loading…
x
Reference in New Issue
Block a user