fix(md-deck): Make active card state reactive
Wrap active in a getter so it updates when activeTab changes.
This commit is contained in:
@@ -38,12 +38,12 @@ export function CardList(props: CardListProps) {
|
||||
<For each={pageCards()}>
|
||||
{(card, index) => {
|
||||
const globalIndex = () => page() * PAGE_SIZE + index();
|
||||
const active = store.state.activeTab === globalIndex();
|
||||
const active = () => store.state.activeTab === globalIndex();
|
||||
return (
|
||||
<button
|
||||
onClick={() => store.actions.setActiveTab(globalIndex())}
|
||||
class={`flex items-center gap-2 w-full text-left px-3 py-2 rounded text-sm font-medium transition-colors cursor-pointer ${
|
||||
active
|
||||
active()
|
||||
? "bg-blue-100 text-blue-600"
|
||||
: "text-gray-600 hover:bg-gray-100"
|
||||
}`}
|
||||
|
||||
Reference in New Issue
Block a user