Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melsumner/issue 378 #379

Merged
merged 12 commits into from
Aug 5, 2024
Merged

Melsumner/issue 378 #379

merged 12 commits into from
Aug 5, 2024

Conversation

MelSumner
Copy link
Member

@MelSumner MelSumner commented Jul 30, 2024

If merged, this PR resolves the issue described in #378

Details

  • added 3 additional tests for potential combinations
  • updated the hasQueryParams check so that it checks for more combinations
  • updated the hasQueryParams check to be more terse
  • updated the description of the getter/param
  • added a check in the onRouteChange action to compare routes

After review/any changes/approval, I'll squash/merge and do a patch release.

@MelSumner MelSumner marked this pull request as ready for review July 30, 2024 19:44
@MelSumner
Copy link
Member Author

@deanmarano can you check this and see if this is what you would expect? TYSM!

Copy link
Contributor

@ef4 ef4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me.

@@ -173,5 +173,77 @@ 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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is meant to cover a scenario like this:

myurl.com/someRoute --> myurl.com/someRoute?someQueryParam=foo

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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is meant to cover a scenario like this:

myurl.com/someRoute?someQueryParam=foo --> myurl.com/someRoute

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) {
Copy link
Member Author

@MelSumner MelSumner Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is meant to cover a scenario like this:

myurl.com/someRoute?someQueryParam=foo --> myurl.com/someOtherRoute

Comment on lines +110 to +112
let hasSameRoute = this.transition.from.name === this.transition.to.name;

if (this.excludeAllQueryParams && this.hasQueryParams && hasSameRoute) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the failing test pass, but I also wonder if there's a more elegant way to do this. Suggestions welcome.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The this.hasQueryParams might not be needed with the hasSameRoute.

await render(hbs`<NavigationNarrator @excludeAllQueryParams={{true}} />`);
router.trigger(
'routeDidChange',
new MockTransition({
Copy link
Member Author

@MelSumner MelSumner Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same format found here, with a query param added to the from:

test('when routes differ', function (assert) {

@MelSumner MelSumner merged commit 7fe1789 into main Aug 5, 2024
6 checks passed
@MelSumner MelSumner deleted the melsumner/issue-378 branch August 5, 2024 18:31
@MelSumner MelSumner restored the melsumner/issue-378 branch August 8, 2024 16:04
MelSumner added a commit that referenced this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants