FIX: URL fragments not purging (#19324)
Fixes issue introduced in commit 2704a02e3a
. Once a user visited an in-page anchor, that URL "stuck" in the browser's address bar. See also https://meta.discourse.org/t/anchors-url-not-purge-when-page-changed/244484 for a detailed report.
This commit is contained in:
parent
e5a18dddac
commit
57fe57e7ce
|
@ -216,7 +216,7 @@ const DiscourseURL = EmberObject.extend({
|
|||
const m = /^#(.+)$/.exec(path);
|
||||
if (m) {
|
||||
this.jumpToElement(m[1]);
|
||||
return;
|
||||
return this.replaceState(path);
|
||||
}
|
||||
|
||||
const oldPath = this.router.currentURL;
|
||||
|
|
|
@ -154,10 +154,15 @@ module("Unit | Utility | url", function () {
|
|||
|
||||
test("anchor handling", async function (assert) {
|
||||
sinon.stub(DiscourseURL, "jumpToElement");
|
||||
sinon.stub(DiscourseURL, "replaceState");
|
||||
DiscourseURL.routeTo("#heading1");
|
||||
assert.ok(
|
||||
DiscourseURL.jumpToElement.calledWith("heading1"),
|
||||
"in-page anchors call jumpToElement"
|
||||
);
|
||||
assert.ok(
|
||||
DiscourseURL.replaceState.calledWith("#heading1"),
|
||||
"in-page anchors call replaceState with the url fragment"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue