Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(quill): keep the link role on buttons that render a link (#120069)

Daniel Marchuk962606a096c3
diff --git a/packages/quill/packages/primitives/src/button.tsx b/packages/quill/packages/primitives/src/button.tsx
index 8ac275e569c7..2527bf241470 100644
--- a/packages/quill/packages/primitives/src/button.tsx
+++ b/packages/quill/packages/primitives/src/button.tsx
@@ -97,6 +97,13 @@ function rendersNonButton(render: ButtonPrimitive.Props['render']): boolean {
* A disabled button keeps no destination. The browser handles a modifier click on a rendered link
* before any click guard runs, so a kept `href` or `to` would still open in a new tab.
*/
+function rendersLink(render: ButtonPrimitive.Props['render']): boolean {
+ return (
+ React.isValidElement<{ to?: unknown; href?: unknown }>(render) &&
+ (render.props.to !== undefined || render.props.href !== undefined)
+ )
+}
+
function withoutDestination(render: ButtonPrimitive.Props['render']): ButtonPrimitive.Props['render'] {
if (!React.isValidElement<{ to?: unknown; href?: unknown }>(render)) {
return render
@@ -141,6 +148,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
disabled={isDisabled}
nativeButton={nativeButton ?? !rendersNonButton(renderTarget)}
render={renderTarget}
+ // Base UI gives every non-native button role="button", which would hide a rendered link
+ // from link queries and screen readers. A caller's own role still wins.
+ {...(rendersLink(renderTarget) ? { role: 'link' } : {})}
// While loading, stay focusable: Base UI then renders aria-disabled instead of
// the native disabled attribute, keeping the button in the tab order so screen
// readers can reach it and announce busy. Activation stays blocked. A disabled