Skip to content

Commit 69c51cb

Browse files
authored
Fix charm list view auto-dismiss (commontoolsinc#1945)
* Fix charm list view auto-dismiss We regressed when reworking the 'active charm' concept. Clicking the 🔍 should show the charms list, clicking an item should navigate to it and dismiss the list. After our recent changes, we no longer automatically dismissed the list. This PR corrects that behaviour. * Format pass
1 parent d939cbc commit 69c51cb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/shell/src/lib/app/state.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export function applyCommand(
3535
switch (command.type) {
3636
case "set-active-charm-id": {
3737
next.activeCharmId = command.charmId;
38+
if (command.charmId) {
39+
next.showShellCharmListView = false;
40+
}
3841
break;
3942
}
4043
case "set-identity": {

packages/shell/test/app-state.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it } from "@std/testing/bdd";
22
import {
3+
applyCommand,
34
AppState,
45
AppStateSerialized,
56
deserialize,
@@ -69,4 +70,18 @@ describe("AppState", () => {
6970
assert(state.spaceName === SPACE_NAME);
7071
assert(state.identity?.did() === identity.did(), "deserializes identity.");
7172
});
73+
74+
it("clears charm list view when activating a charm", () => {
75+
const initial: AppState = {
76+
apiUrl: new URL(API_URL),
77+
showShellCharmListView: true,
78+
};
79+
80+
const next = applyCommand(initial, {
81+
type: "set-active-charm-id",
82+
charmId: "example",
83+
});
84+
85+
assert(next.showShellCharmListView === false);
86+
});
7287
});

0 commit comments

Comments
 (0)