ember-nav-stack 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## v6.1.1 (2025-12-02)
2
+
1
3
  ## v6.1.0 (2025-10-30)
2
4
 
3
5
  ## v6.0.3 (2024-03-01)
@@ -520,7 +520,6 @@ export default class NavStack extends Component {
520
520
  this.parentHeaderElement,
521
521
  this.currentHeaderElement,
522
522
  );
523
- run(this.args, this.args.back);
524
523
  } else {
525
524
  setTransform(this.containerElement, `translateX(${this.startingX}px)`);
526
525
  styleHeaderElements(
@@ -544,6 +543,9 @@ export default class NavStack extends Component {
544
543
  }
545
544
  this.navStacksService.notifyTransitionEnd();
546
545
  this._activeSpring = null;
546
+ if (shouldNavigateBack) {
547
+ run(this.args, this.args.back);
548
+ }
547
549
  };
548
550
  if (fromValue === toValue && initialVelocity === 0) {
549
551
  finalize();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-nav-stack",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "The default blueprint for ember-cli addons.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -1,2 +0,0 @@
1
- {
2
- }
@@ -1,125 +0,0 @@
1
- # Ember Nav Stack – Robust Test Waiters Plan
2
-
3
- ## Goal
4
-
5
- - Make `ember-nav-stack`’s waiter coverage fully robust so `@ember/test-helpers` built-in waiting (from `visit`, `click`, etc.) is sufficient. Downstream apps should not need custom helpers like `waitForNavStackIdle` nor ad hoc `waitFor`/`waitUntil` for nav stabilization.
6
-
7
- ## Background
8
-
9
- - Current service file: `ember-nav-stack/addon/services/nav-stacks.js`.
10
- - Today it creates a single waiter (`buildWaiter('ember-nav-stack:transition-waiter')`) and brackets only animation transitions via `notifyTransitionStart`/`notifyTransitionEnd`.
11
- - Pushing/removing items drives updates through `scheduleOnce('afterRender', this, this._process)`, which recomputes `stacks`, notifies listeners, and toggles `isInitialRender`.
12
- - Gaps:
13
- - No waiter covers the coalesced “stack recompute + listener render” cycle triggered by `pushItem`/`removeItem`.
14
- - No waiter covers the very first materialization (“initial render”) of the stack DOM.
15
- - Consequence in consumers: tests inject extra waits (custom helpers and repeated `waitFor` calls) to stabilize views after navigation.
16
- - Ember test semantics: `visit`/`click` already await “settled” (routing + runloop + registered waiters). If nav-stack marks all relevant async spans, tests can assert immediately after these helpers.
17
-
18
- ## Design Overview
19
-
20
- - Introduce a second waiter to cover stack recompute + render: “stack-update waiter”.
21
- - Keep a dedicated “transition waiter” for CSS/animation-driven transitions (rename for clarity).
22
- - Add a one-time “initial render” waiter so tests don’t race the first DOM materialization.
23
- - End the stack waiter only after the listener-rendered DOM is visible (i.e., after `afterRender` and one `next()` tick).
24
- - Maintain aggregated semantics:
25
- - Transitions: first start begins the waiter; last end closes it.
26
- - Stack updates: coalesced updates begin once and end once per `_process` batch.
27
-
28
- ## Detailed Changes (Service)
29
-
30
- - File: `addon/services/nav-stacks.js`
31
-
32
- ### Waiters and Tokens
33
-
34
- - Module scope:
35
- - `let transitionWaiter = buildWaiter('ember-nav-stack:transition');`
36
- - `let stackWaiter = buildWaiter('ember-nav-stack:stack-update');`
37
- - Class state:
38
- - `transitionToken` (replaces generic `waiterToken`).
39
- - `_stackUpdateToken` (undefined when no coalesced update is pending).
40
- - `_initialRenderToken` (undefined after first materialization completes).
41
- - `_runningTransitions` counter (kept as-is).
42
-
43
- ### Initial Render Coverage
44
-
45
- - In `constructor()`:
46
- - `this._initialRenderToken = stackWaiter.beginAsync();`
47
- - Keep `this.isInitialRender = true` as today.
48
- - In `_process()` (after recomputing `stacks` and notifying listeners):
49
- - Schedule `next(() => { if (this.isInitialRender && this._initialRenderToken) { stackWaiter.endAsync(this._initialRenderToken); this._initialRenderToken = undefined; } this._maybeResolveIdle(); })`.
50
- - Keep the existing `next(this, this._clearIsInitialRender)` behavior.
51
-
52
- ### Stack Recompute + Render Coverage
53
-
54
- - In `_schedule()`:
55
- - Keep `scheduleOnce('afterRender', this, this._process)`.
56
- - Begin the stack-update waiter when scheduling a batch (if not already begun):
57
- - `if (!this._stackUpdateToken) { this._stackUpdateToken = stackWaiter.beginAsync(); }`
58
- - In `_process()` (after setting stacks and notifying listeners):
59
- - End the coalesced batch on the next tick to ensure DOM is fully flushed:
60
- - `next(() => { if (this._stackUpdateToken) { stackWaiter.endAsync(this._stackUpdateToken); this._stackUpdateToken = undefined; } this._maybeResolveIdle(); })`
61
-
62
- ### Transition Waiter Semantics
63
-
64
- - `notifyTransitionStart()`:
65
- - `if (++this._runningTransitions === 1) { this.transitionToken = transitionWaiter.beginAsync(); }`
66
- - `notifyTransitionEnd()`:
67
- - `if (--this._runningTransitions === 0) { transitionWaiter.endAsync(this.transitionToken); this.transitionToken = undefined; }`
68
- - `next(() => this._maybeResolveIdle());`
69
- - Optional: guard negative counts defensively if a caller misorders starts/ends.
70
-
71
- ## Why This Works
72
-
73
- - `@ember/test-helpers` waits for registered waiters between async helpers. With transitions and stack recompute wrapped, `visit`/`click` will naturally pause until:
74
- - Routing settles.
75
- - Data sources settle (handled by consumers’ waiters like Orbit).
76
- - Nav-stack animations settle (transition waiter).
77
- - Nav-stack recompute + listener render fully flush (stack-update waiter).
78
- - Tests can assert immediately after `await visit()` / `await click()` with no additional `settled()`/`waitFor`.
79
-
80
- ## Test Plan (Within ember-nav-stack)
81
-
82
- - Initial render waiter:
83
- - Mount a listener that renders an item. Assert `hasPendingWaiters()` is true until first flush completes.
84
- - Coalesced stack updates:
85
- - Call `pushItem` twice in one runloop; assert one `_process` and a single waiter span; no pending waiters after the `next` tick.
86
- - Transition waiter behavior:
87
- - Call `notifyTransitionStart()` n times, then `notifyTransitionEnd()` n times; assert waiter opens on first and closes on last.
88
- - Black-box flow:
89
- - Simulate a click that causes a stack push; after `await click`, assert DOM reflects new item without extra waits.
90
-
91
- ## Consumer Implications (e.g., yapp-core)
92
-
93
- - After upgrading ember-nav-stack:
94
- - Remove custom `waitForNavStackIdle` helper usages.
95
- - Remove redundant `waitFor`/`waitUntil` after navigation actions.
96
- - Continue relying on existing data-source waiters (e.g., Orbit) and ensure other async (e.g., translations) is wrapped by test-waiters (outside nav-stack scope).
97
-
98
- ## Performance & Production Impact
99
-
100
- - Waiter tokens are opened only on meaningful work (transition start, coalesced stack update, initial render) and coalesce naturally.
101
- - `@ember/test-waiters` strips most behavior in production builds, so runtime impact remains negligible in prod.
102
-
103
- ## Risks & Edge Cases
104
-
105
- - Ensure all transitions reliably call `notifyTransitionStart/End` (including cancellation/unmount paths).
106
- - Third-party animations not integrated with nav-stack are not covered; prefer routing/transitions to go through nav-stack or add integration points.
107
- - If a listener performs DOM-affecting async outside Ember’s runloop, either bring it into the runloop or instrument it with a narrow waiter in that component.
108
-
109
- ## Deliverables Checklist
110
-
111
- - [ ] Add `transitionWaiter` and `stackWaiter` in `addon/services/nav-stacks.js`.
112
- - [ ] Add `transitionToken`, `_stackUpdateToken`, `_initialRenderToken` fields.
113
- - [ ] Begin `_initialRenderToken` in `constructor`.
114
- - [ ] Begin `_stackUpdateToken` in `_schedule` (if absent).
115
- - [ ] End `_stackUpdateToken` and `_initialRenderToken` inside `next()` in `_process`.
116
- - [ ] Keep transition waiter around `notifyTransitionStart/End` (rename field for clarity).
117
- - [ ] Add unit/integration tests for the behaviors above.
118
- - [ ] README/Docs note: “With robust waiters, `visit`/`click` do not require extra waits.”
119
-
120
- ## Acceptance Criteria
121
-
122
- - In a consumer app: after `await visit()` or `await click()`, nav-stack content is immediately assertable without extra waits.
123
- - Reduction in test flakiness associated with navigation and stack updates.
124
- - No regressions in production behavior.
125
-