Skip to content

[docs] Copy button pulls the wrong code sample #1403

Open
@FlippingBinary

Description

@FlippingBinary

Describe the bug

The wrong code sample gets copied when clicking the copy button on the TS code sample under route in the Using URL data section. This only happens with that specific TS code sample, not the JS code sample or any other code sample that I tested.

When triggered, the following text is copied into the clipboard:

console.log('hello world');
// Prints: hello world, to stdout
console.log('hello %s', 'world');
// Prints: hello world, to stdout
console.error(new Error('Whoops, something bad happened'));
// Prints error message and stack trace to stderr:
//   Error: Whoops, something bad happened
//     at [eval]:5:15
//     at Script.runInThisContext (node:vm:132:18)
//     at Object.runInThisContext (node:vm:309:38)
//     at node:internal/process/execution:77:19
//     at [eval]-wrapper:6:22
//     at evalScript (node:internal/process/execution:76:60)
//     at node:internal/main/eval_string:23:3

const name = 'Will Robinson';
console.warn(`Danger ${name}! Danger!`);
// Prints: Danger Will Robinson! Danger!, to stderr

Reproduction

  1. Navigate to https://svelte.dev/docs/kit/load#Using-URL-data-route
  2. Make sure the TS code sample is displayed.
  3. Click the copy button.
Image
  1. Paste the text elsewhere.

Image

Logs

No messages appear in the console log.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (32) x64 Intel(R) Core(TM) i9-14900K
    Memory: 133.29 GB / 159.70 GB
  Binaries:
    Node: 22.16.0 - C:\nvm4w\nodejs\node.EXE
    npm: 11.4.1 - C:\nvm4w\nodejs\npm.CMD
    pnpm: 10.12.4 - ~\AppData\Local\Microsoft\WinGet\Links\pnpm.EXE
  Browsers:
    Edge: Chromium (137.0.3296.83)

Severity

annoyance

Additional Information

Vivaldi is my primary browser. For sanity, I also tested it in Edge and asked someone on BlueSky to confirm.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions