Skip to content

Commit 9a4122f

Browse files
committed
fix(share): stop the fallback link erasing itself
When the clipboard is unavailable the link goes in the address bar instead. Assigning location.hash fires a hashchange, which is what the editor listens for to open a link somebody has pasted, so it read the link straight back as an incoming one, said so, and cleared the address bar again. Pressing Share left nothing behind and a banner claiming the config had arrived from a link. replaceState puts it there without the event.
1 parent 15d65e0 commit 9a4122f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/components/header/header.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,12 @@ export class HeaderComponent {
554554
} catch {
555555
// Denied clipboard permission, or an insecure origin. Putting the link
556556
// in the address bar at least leaves it somewhere copyable.
557-
globalThis.location.hash = new URL(link).hash;
557+
//
558+
// replaceState rather than assigning location.hash, which fires a
559+
// hashchange: the editor listens for that to open a link somebody has
560+
// pasted, so writing the link would have been read straight back as one
561+
// and cleared the address bar again.
562+
globalThis.history.replaceState(null, "", link);
558563
this.importStatus.set({
559564
tone: "success",
560565
message: "Link ready in the address bar; copying it was blocked by the browser.",

0 commit comments

Comments
 (0)