Skip to content

Copy-identifier button copies extra text when accessibility software prefixes title #155032

@Enyium

Description

@Enyium

Code Link

Every generated docs page, like, e.g., for std::fs or std::fs::read_to_string().

Reproduction Steps

  • Install Rango and all of its prerequisites, which is accessibility software that allows you to control web browsers by voice. As you can see in this video, it changes tab titles (<title> DOM elements) to prefix them with hints that allow you to reference the tabs.
    • As an easier alternative, use the browser dev tools to prefix the tab title (<hmtl> -> <head> -> <title>) to simulate how Rango or some other software changes titles.
  • Click on the clipboard icon at the top of the page to the right of the identifier that the page documents.
  • Paste the clipboard contents somewhere.

Expected Outcome

Something like std::fs or std::fs::read_to_string.

Actual Output

Something like gg | std::fs or std::fs::ev | read_to_string.

Version

That currently used by docs.rs. Nightly according to AI.

Additional Details

As the click event handler code for the clipboard icon button, Firefox shows me:

() => {
  const titleElement = document.querySelector("title");
  const title = titleElement && titleElement.textContent ? titleElement.textContent.replace(" - Rust", "") : "";
  const [item, module] = title.split(" in ");
  const path = [item];
  if (module !== undefined) {
    path.unshift(module);
  }
  copyContentToClipboard(path.join("::"));
  copyButtonAnimation(but);
}

The code should use a dedicated source for the text to be copied and not the tab title from the DOM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions