MCPcopy Index your code
hub / github.com/refined-github/refined-github / createTooltipFor

Function createTooltipFor

source/helpers/tooltip.tsx:29–55  ·  view source on GitHub ↗
(element: Element, content: string | TooltipOptions)

Source from the content-addressed store, hash-verified

27}
28
29function createTooltipFor(element: Element, content: string | TooltipOptions): HTMLElement {
30 const options: TooltipOptions = typeof content === 'string'
31 ? {label: content}
32 : content;
33
34 // Ensure the element has an ID for the `for` attribute to link to
35 element.id ||= crypto.randomUUID();
36
37 const tooltipId = crypto.randomUUID();
38 element.setAttribute('aria-labelledby', tooltipId);
39
40 return (
41 <tool-tip
42 id={tooltipId}
43 className="sr-only position-absolute"
44 for={element.id}
45 popover="manual"
46 data-direction={options.direction ?? 's'}
47 data-type={options.type ?? 'label'}
48 aria-hidden="true"
49 role="tooltip"
50 >
51 {options.label}
52 {options.shortcut && renderShortcut(options.shortcut)}
53 </tool-tip>
54 );
55}
56
57/**
58Align tooltip behavior with native

Callers 2

tooltippedFunction · 0.85
addTooltipFunction · 0.85

Calls 1

renderShortcutFunction · 0.85

Tested by

no test coverage detected