natus wheel: fix DON/DOFF reset on PRV/NXT return to DONned planet — TDD
_aspectsVisible was set to false when stepping away to a different planet, but the guard `if (item0.name !== _aspectPlanet)` only skipped resetting it on return — it never restored it to true. Replace the conditional with a direct assignment: _aspectsVisible = (item0.name === _aspectPlanet). T11g: navigating away via NXT then back via PRV restores DOFF-active state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -344,12 +344,11 @@ const NatusWheel = (() => {
|
|||||||
/** Lock-activate a planet by cycle index. */
|
/** Lock-activate a planet by cycle index. */
|
||||||
function _activatePlanet(idx) {
|
function _activatePlanet(idx) {
|
||||||
_clearActive();
|
_clearActive();
|
||||||
// Aspect lines persist across planet switches — cleared only by DON or DOFF.
|
// _aspectsVisible tracks whether the currently-active planet's aspects are drawn.
|
||||||
// Re-opening the same planet restores _aspectsVisible so DON shows as ×.
|
// Derive it from _aspectPlanet so navigating away and back via PRV/NXT correctly
|
||||||
|
// restores the DOFF state instead of resetting to DON.
|
||||||
const item0 = _planetItems[idx];
|
const item0 = _planetItems[idx];
|
||||||
if (item0.name !== _aspectPlanet) {
|
_aspectsVisible = (item0.name === _aspectPlanet);
|
||||||
_aspectsVisible = false;
|
|
||||||
}
|
|
||||||
_activeRing = 'planets';
|
_activeRing = 'planets';
|
||||||
_activeIdx = idx;
|
_activeIdx = idx;
|
||||||
const item = _planetItems[idx];
|
const item = _planetItems[idx];
|
||||||
|
|||||||
@@ -429,6 +429,26 @@ describe("NatusWheel — DON/DOFF aspect line persistence", () => {
|
|||||||
expect(donDisabled()).toBe(false);
|
expect(donDisabled()).toBe(false);
|
||||||
expect(aspectLines()).toBe(0);
|
expect(aspectLines()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// T11g — PRV/NXT navigation back to a DONned planet must restore DOFF state
|
||||||
|
it("T11g: navigating away via NXT then back via PRV restores DOFF-active state", () => {
|
||||||
|
clickPlanet("Sun");
|
||||||
|
clickDon();
|
||||||
|
expect(donDisabled()).toBe(true); // DON disabled, aspects active
|
||||||
|
|
||||||
|
// Navigate away to next planet
|
||||||
|
tooltipEl.querySelector(".nw-tt-nxt")
|
||||||
|
.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||||
|
expect(donDisabled()).toBe(false); // new planet — DON fresh/active
|
||||||
|
|
||||||
|
// Navigate back to Sun
|
||||||
|
tooltipEl.querySelector(".nw-tt-prv")
|
||||||
|
.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||||
|
|
||||||
|
// Sun's aspects are still drawn — DOFF must be active, DON must be disabled
|
||||||
|
expect(donDisabled()).toBe(true);
|
||||||
|
expect(aspectLines()).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe("NatusWheel — half-wheel tooltip positioning", () => {
|
xdescribe("NatusWheel — half-wheel tooltip positioning", () => {
|
||||||
|
|||||||
@@ -429,6 +429,26 @@ describe("NatusWheel — DON/DOFF aspect line persistence", () => {
|
|||||||
expect(donDisabled()).toBe(false);
|
expect(donDisabled()).toBe(false);
|
||||||
expect(aspectLines()).toBe(0);
|
expect(aspectLines()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// T11g — PRV/NXT navigation back to a DONned planet must restore DOFF state
|
||||||
|
it("T11g: navigating away via NXT then back via PRV restores DOFF-active state", () => {
|
||||||
|
clickPlanet("Sun");
|
||||||
|
clickDon();
|
||||||
|
expect(donDisabled()).toBe(true); // DON disabled, aspects active
|
||||||
|
|
||||||
|
// Navigate away to next planet
|
||||||
|
tooltipEl.querySelector(".nw-tt-nxt")
|
||||||
|
.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||||
|
expect(donDisabled()).toBe(false); // new planet — DON fresh/active
|
||||||
|
|
||||||
|
// Navigate back to Sun
|
||||||
|
tooltipEl.querySelector(".nw-tt-prv")
|
||||||
|
.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||||
|
|
||||||
|
// Sun's aspects are still drawn — DOFF must be active, DON must be disabled
|
||||||
|
expect(donDisabled()).toBe(true);
|
||||||
|
expect(aspectLines()).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xdescribe("NatusWheel — half-wheel tooltip positioning", () => {
|
xdescribe("NatusWheel — half-wheel tooltip positioning", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user