From 1946f65f731f509085125d60b1632f19deca9111 Mon Sep 17 00:00:00 2001 From: Melanie Sumner Date: Thu, 8 Aug 2024 12:04:35 -0400 Subject: [PATCH] Revert "Melsumner/issue 378 (#379)" This reverts commit 7fe1789c1e9f74be13945660019acbfe937729be. --- addon/components/navigation-narrator.js | 16 ++-- package.json | 1 - pnpm-lock.yaml | 88 ------------------- .../components/navigation-narrator-test.js | 83 ----------------- 4 files changed, 7 insertions(+), 181 deletions(-) diff --git a/addon/components/navigation-narrator.js b/addon/components/navigation-narrator.js index 9bb7596..490a5bb 100644 --- a/addon/components/navigation-narrator.js +++ b/addon/components/navigation-narrator.js @@ -76,14 +76,15 @@ export default class NavigationNarratorComponent extends Component { /* * @param hasQueryParams * @type {boolean} - * @description Check for queryParams. + * @description Detect if the `transition.from` or the `transition.to` has queryParams. * @default false */ get hasQueryParams() { - if ( - Object.keys(this.transition.from.queryParams || {}).length || - Object.keys(this.transition.to.queryParams).length > 0 - ) { + const qps = + (this.transition.from && this.transition.from.queryParams) || + (this.transition.to && this.transition.to.queryParams); + + if (qps && Object.keys(qps).length > 0) { return true; } else { return false; @@ -107,10 +108,7 @@ export default class NavigationNarratorComponent extends Component { let shouldFocus; this.transition = transition; // We need to do this because we can't pass an argument to a getter - // add a check to see if it's the same route (question: what if the user refreshes the page?) - let hasSameRoute = this.transition.from.name === this.transition.to.name; - - if (this.excludeAllQueryParams && this.hasQueryParams && hasSameRoute) { + if (this.excludeAllQueryParams && this.hasQueryParams) { return; } diff --git a/package.json b/package.json index 9ec64a7..2a2c1ed 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", "loader.js": "^4.7.0", - "npm-run-all": "^4.1.5", "npm-run-all2": "^5.0.0", "prettier": "^2.5.1", "qunit": "^2.17.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a71eb9..14cb57b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -126,9 +126,6 @@ importers: loader.js: specifier: ^4.7.0 version: 4.7.0 - npm-run-all: - specifier: ^4.1.5 - version: 4.1.5 npm-run-all2: specifier: ^5.0.0 version: 5.0.2 @@ -4608,10 +4605,6 @@ packages: livereload-js@3.4.1: resolution: {integrity: sha512-5MP0uUeVCec89ZbNOT/i97Mc+q3SxXmiUGhRFOTmhrGPn//uWVQdCvcLJDy64MSBR5MidFdOR7B9viumoavy6g==} - load-json-file@4.0.0: - resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==} - engines: {node: '>=4'} - loader-runner@2.4.0: resolution: {integrity: sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw==} engines: {node: '>=4.3.0 <5.0.0 || >=5.10'} @@ -5212,11 +5205,6 @@ packages: engines: {node: '>= 10'} hasBin: true - npm-run-all@4.1.5: - resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==} - engines: {node: '>= 4'} - hasBin: true - npm-run-path@2.0.2: resolution: {integrity: sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==} engines: {node: '>=4'} @@ -5436,10 +5424,6 @@ packages: resolution: {integrity: sha512-CTM5kuWR3sx9IFamcl5ErfPl6ea/N8IYwiJ+vpeB2g+1iknv7zBl5uPwbMbRVznRVbrNY6lGuDoE5b30grmbqg==} engines: {node: '>= 0.10'} - parse-json@4.0.0: - resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} - engines: {node: '>=4'} - parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -5521,10 +5505,6 @@ packages: path-to-regexp@0.1.7: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} - path-type@3.0.0: - resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} - engines: {node: '>=4'} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -5540,20 +5520,11 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - pidtree@0.3.1: - resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==} - engines: {node: '>=0.10'} - hasBin: true - pidtree@0.5.0: resolution: {integrity: sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA==} engines: {node: '>=0.10'} hasBin: true - pify@3.0.0: - resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} - engines: {node: '>=4'} - pify@4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} @@ -5808,10 +5779,6 @@ packages: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true - read-pkg@3.0.0: - resolution: {integrity: sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==} - engines: {node: '>=4'} - read-pkg@5.2.0: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} @@ -6450,10 +6417,6 @@ packages: resolution: {integrity: sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==} engines: {node: '>= 0.4'} - string.prototype.padend@3.1.6: - resolution: {integrity: sha512-XZpspuSB7vJWhvJc9DLSlrXl1mcA2BdoY5jjnS135ydXqLoqhs96JjDtCkjJEQHvfqZIp9hBuBMgI589peyx9Q==} - engines: {node: '>= 0.4'} - string.prototype.trim@1.2.9: resolution: {integrity: sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==} engines: {node: '>= 0.4'} @@ -6490,10 +6453,6 @@ packages: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} - strip-bom@3.0.0: - resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} - engines: {node: '>=4'} - strip-bom@4.0.0: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} @@ -13574,13 +13533,6 @@ snapshots: livereload-js@3.4.1: {} - load-json-file@4.0.0: - dependencies: - graceful-fs: 4.2.11 - parse-json: 4.0.0 - pify: 3.0.0 - strip-bom: 3.0.0 - loader-runner@2.4.0: {} loader-runner@4.3.0: {} @@ -14331,18 +14283,6 @@ snapshots: read-pkg: 5.2.0 shell-quote: 1.8.1 - npm-run-all@4.1.5: - dependencies: - ansi-styles: 3.2.1 - chalk: 2.4.2 - cross-spawn: 6.0.5 - memorystream: 0.3.1 - minimatch: 3.1.2 - pidtree: 0.3.1 - read-pkg: 3.0.0 - shell-quote: 1.8.1 - string.prototype.padend: 3.1.6 - npm-run-path@2.0.2: dependencies: path-key: 2.0.1 @@ -14589,11 +14529,6 @@ snapshots: pbkdf2: 3.1.2 safe-buffer: 5.2.1 - parse-json@4.0.0: - dependencies: - error-ex: 1.3.2 - json-parse-better-errors: 1.0.2 - parse-json@5.2.0: dependencies: '@babel/code-frame': 7.24.6 @@ -14660,10 +14595,6 @@ snapshots: path-to-regexp@0.1.7: {} - path-type@3.0.0: - dependencies: - pify: 3.0.0 - path-type@4.0.0: {} pbkdf2@3.1.2: @@ -14678,12 +14609,8 @@ snapshots: picomatch@2.3.1: {} - pidtree@0.3.1: {} - pidtree@0.5.0: {} - pify@3.0.0: {} - pify@4.0.1: {} pinkie-promise@2.0.1: @@ -14947,12 +14874,6 @@ snapshots: minimist: 1.2.8 strip-json-comments: 2.0.1 - read-pkg@3.0.0: - dependencies: - load-json-file: 4.0.0 - normalize-package-data: 2.5.0 - path-type: 3.0.0 - read-pkg@5.2.0: dependencies: '@types/normalize-package-data': 2.4.4 @@ -15742,13 +15663,6 @@ snapshots: set-function-name: 2.0.2 side-channel: 1.0.6 - string.prototype.padend@3.1.6: - dependencies: - call-bind: 1.0.7 - define-properties: 1.2.1 - es-abstract: 1.23.3 - es-object-atoms: 1.0.0 - string.prototype.trim@1.2.9: dependencies: call-bind: 1.0.7 @@ -15794,8 +15708,6 @@ snapshots: dependencies: ansi-regex: 5.0.1 - strip-bom@3.0.0: {} - strip-bom@4.0.0: {} strip-eof@1.0.0: {} diff --git a/tests/integration/components/navigation-narrator-test.js b/tests/integration/components/navigation-narrator-test.js index 8573196..5373610 100644 --- a/tests/integration/components/navigation-narrator-test.js +++ b/tests/integration/components/navigation-narrator-test.js @@ -173,88 +173,5 @@ module('Integration | Component | navigation-narrator', function (hooks) { assert.dom('#ember-a11y-refocus-nav-message').isFocused(); }); - - test('excludeAllQueryParams is true, queryParams do not exist but are added, do not manage focus', async function (assert) { - let router = this.owner.lookup('service:router'); - - await render(hbs``); - router.trigger( - 'routeDidChange', - new MockTransition({ - from: new MockRouteInfo({ - name: 'biscuit', - params: { id: 'hobnob' }, - }), - to: new MockRouteInfo({ - name: 'biscuit', - params: { id: 'hobnob' }, - queryParams: { region: 'apac' }, - }), - }) - ); - - await settled(); - - assert.dom('#ember-a11y-refocus-nav-message').isNotFocused(); - }); - - test('excludeAllQueryParams is true, queryParams exist on the route but then are emptied, still do not manage focus', async function (assert) { - let router = this.owner.lookup('service:router'); - - await render(hbs``); - router.trigger( - 'routeDidChange', - new MockTransition({ - from: new MockRouteInfo({ - name: 'biscuit', - params: { id: 'hobnob' }, - queryParams: { region: 'apac' }, - }), - to: new MockRouteInfo({ - name: 'biscuit', - params: { id: 'hobnob' }, - }), - }) - ); - - await settled(); - - assert.dom('#ember-a11y-refocus-nav-message').isNotFocused(); - }); - - test('excludeAllQueryParams is true, queryParams exist on the route, user navigates to new route without any query params, manage focus', async function (assert) { - let router = this.owner.lookup('service:router'); - - await render(hbs``); - router.trigger( - 'routeDidChange', - new MockTransition({ - from: new MockRouteInfo({ - name: 'biscuit', - params: { id: 'hobnob' }, - queryParams: { region: 'apac' }, - parent: new MockRouteInfo({ - name: 'biscuits', - parent: new MockRouteInfo({ - name: 'application', - }), - }), - }), - to: new MockRouteInfo({ - name: 'index', - parent: new MockRouteInfo({ - name: 'cakes', - parent: new MockRouteInfo({ - name: 'application', - }), - }), - }), - }) - ); - - await settled(); - - assert.dom('#ember-a11y-refocus-nav-message').isFocused(); - }); }); });