Have links clickable within tooltips without clicking content below them (#3204)

* Have links clickable within tooltips without clicking content below them

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* Re-run CI

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* Re-run CI

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Frank Noirot
2024-08-02 12:25:57 -04:00
committed by GitHub
parent 7b9f40c4cb
commit 9b594efe53
6 changed files with 103 additions and 96 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -190,17 +190,23 @@ export function Toolbar({
maybeIconConfig[0].onClick(configCallbackProps) maybeIconConfig[0].onClick(configCallbackProps)
} }
> >
<ToolbarItemContents <span
className={!maybeIconConfig[0].showTitle ? 'sr-only' : ''}
>
{maybeIconConfig[0].title}
</span>
</ActionButton>
<ToolbarItemTooltip
itemConfig={maybeIconConfig[0]} itemConfig={maybeIconConfig[0]}
configCallbackProps={configCallbackProps} configCallbackProps={configCallbackProps}
/> />
</ActionButton>
</ActionButtonDropdown> </ActionButtonDropdown>
) )
} }
const itemConfig = maybeIconConfig const itemConfig = maybeIconConfig
return ( return (
<div className="relative" key={itemConfig.id}>
<ActionButton <ActionButton
Element="button" Element="button"
key={itemConfig.id} key={itemConfig.id}
@ -228,11 +234,15 @@ export function Toolbar({
} }
onClick={() => itemConfig.onClick(configCallbackProps)} onClick={() => itemConfig.onClick(configCallbackProps)}
> >
<ToolbarItemContents <span className={!itemConfig.showTitle ? 'sr-only' : ''}>
{itemConfig.title}
</span>
</ActionButton>
<ToolbarItemTooltip
itemConfig={itemConfig} itemConfig={itemConfig}
configCallbackProps={configCallbackProps} configCallbackProps={configCallbackProps}
/> />
</ActionButton> </div>
) )
})} })}
</ul> </ul>
@ -250,7 +260,7 @@ export function Toolbar({
* It contains a tooltip with the title, description, and links * It contains a tooltip with the title, description, and links
* and a hotkey listener * and a hotkey listener
*/ */
const ToolbarItemContents = memo(function ToolbarItemContents({ const ToolbarItemTooltip = memo(function ToolbarItemContents({
itemConfig, itemConfig,
configCallbackProps, configCallbackProps,
}: { }: {
@ -272,11 +282,8 @@ const ToolbarItemContents = memo(function ToolbarItemContents({
) )
return ( return (
<>
<span className={!itemConfig.showTitle ? 'sr-only' : ''}>
{itemConfig.title}
</span>
<Tooltip <Tooltip
inert={false}
position="bottom" position="bottom"
wrapperClassName="!p-4 !pointer-events-auto" wrapperClassName="!p-4 !pointer-events-auto"
contentClassName="!text-left text-wrap !text-xs !p-0 !pb-2 flex gap-2 !max-w-none !w-72 flex-col items-stretch" contentClassName="!text-left text-wrap !text-xs !p-0 !pb-2 flex gap-2 !max-w-none !w-72 flex-col items-stretch"
@ -339,6 +346,5 @@ const ToolbarItemContents = memo(function ToolbarItemContents({
</> </>
)} )}
</Tooltip> </Tooltip>
</>
) )
}) })

View File

@ -57,7 +57,8 @@
transition-delay: var(--_delay); transition-delay: var(--_delay);
} }
:is(:focus-visible) > .tooltipWrapper.withFocus { :is(:focus-visible) > .tooltipWrapper.withFocus,
:focus-within > .tooltipWrapper.withFocus {
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
} }

View File

@ -29,7 +29,7 @@ export default function Tooltip({
return ( return (
<div <div
// @ts-ignore while awaiting merge of this PR for support of "inert" https://github.com/DefinitelyTyped/DefinitelyTyped/pull/60822 // @ts-ignore while awaiting merge of this PR for support of "inert" https://github.com/DefinitelyTyped/DefinitelyTyped/pull/60822
inert={inert} {...{ inert: inert ? '' : undefined }}
role="tooltip" role="tooltip"
className={`p-3 ${ className={`p-3 ${
position !== 'left' && position !== 'right' ? 'px-0' : '' position !== 'left' && position !== 'right' ? 'px-0' : ''