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

fix(router): store root/default page instruction correctly #1869

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

aegenet
Copy link
Contributor

@aegenet aegenet commented Jan 5, 2024

Pull Request

πŸ“– Description

When a user used the browser's "back" button, the root ("/") default page was not correctly reloaded.

🎫 Issues

Resolves #1812.

πŸ‘©β€πŸ’» Reviewer Notes

In the current code (without this PR), all routing instructions are always prepended with - (updateNavigation).

The issue is due to a simple fact: - + (empty) equals -. And - (minus) is used to clear the current path/page. Thus, when we navigate to /, then to another page, the root page is lost and replaced by -.

My current fix simply checks whether the instruction is empty, and if so, it prevent the clear instruction to be added.

πŸ“‘ Test Plan

  • Added new e2e tests for this specific case.
  • Updated the existing tests to reflect a more realistic navigation flow.

⏭ Next Steps

When a user used the browser's "back" button, the root/home page was not correctly loaded.

close aurelia#1812
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Comparison is base (2939211) 88.68% compared to head (a0496cf) 88.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1869      +/-   ##
==========================================
+ Coverage   88.68%   88.76%   +0.08%     
==========================================
  Files         248      248              
  Lines       22334    22337       +3     
  Branches     5198     5200       +2     
==========================================
+ Hits        19806    19827      +21     
+ Misses       2528     2510      -18     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@Sayan751 Sayan751 requested review from jwx and bigopon January 6, 2024 07:27
Copy link
Member

@jwx jwx left a comment

Choose a reason for hiding this comment

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

Thanks for this! Nice job with the test updates.

@Sayan751 Sayan751 merged commit 84e6380 into aurelia:master Jan 12, 2024
26 checks passed
AureliaEffect pushed a commit that referenced this pull request Jan 26, 2024
2.0.0-beta.10 (2024-01-26)

**BREAKING CHANGE:**

* **enums:** string literal types replace const enums (#1870) ([e21e0c9](e21e0c9))

**Features:**

* **route-recognizer:** support for route parameter constraints (#1862) ([8f29cfd](8f29cfd))

**Bug Fixes:**

* **docs:** various doc fix
* **au-slot:** properly handle nested projection registration (#1881) ([00e8dee](00e8dee))
* **kernel:** stack preserving error logging for console (#1884) ([030bfa1](030bfa1))
* **portal:** remove target marker when deactivated (#1883) ([3db4c17](3db4c17))
* **validation:** evaluation of tagged rules from bindings (#1878) ([43d12f6](43d12f6))
* **validation:** property parsing with lambda and istanbul (#1877) ([71f82cf](71f82cf))
* **router:** store root/default page instruction correctly (#1869) ([84e6380](84e6380))
* **runtime-html:** template wrapping  (#1875) ([bfdaa3b](bfdaa3b))
* **i18n:** handle change of key in t.bind (#1868) ([c185764](c185764))
* **router-lite:** Router injection and ignoring null/undefined values for query parameters (#1859) ([6a79bc9](6a79bc9))
* **router-lite:** injection of Router alias ([6a79bc9](6a79bc9))
* **runtime-html:** fix broken tests ([bfdaa3b](bfdaa3b))
@aegenet aegenet deleted the fix/router-popstate-1812 branch February 1, 2024 09:07
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.

router: popstate events are broken with empty routes ('')
3 participants