From 6ea39507a57526e8507dd75b51b141095d210aa0 Mon Sep 17 00:00:00 2001
From: Nicole Thoen <nthoen@redhat.com>
Date: Wed, 16 Oct 2024 13:14:03 -0400
Subject: [PATCH] fix: remove redundant aria-describedby attributes (#243)

* fix: remove redundant aria-describedby attributes

* Update packages/module/src/ResponseActions/ResponseActionButton.tsx

Co-authored-by: Rebecca Alpert <ralpert@redhat.com>

---------

Co-authored-by: Rebecca Alpert <ralpert@redhat.com>
---
 packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx      | 1 -
 .../module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx | 1 -
 packages/module/src/MessageBar/AttachButton.tsx              | 1 -
 packages/module/src/MessageBar/MicrophoneButton.tsx          | 1 -
 packages/module/src/MessageBar/SendButton.tsx                | 1 -
 packages/module/src/MessageBox/JumpButton.tsx                | 1 -
 packages/module/src/ResponseActions/ResponseActionButton.tsx | 5 ++---
 7 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx b/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx
index d49cf8e4..d1d18c90 100644
--- a/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx
+++ b/packages/module/src/ChatbotHeader/ChatbotHeaderMenu.tsx
@@ -25,7 +25,6 @@ export const ChatbotHeaderMenu: React.FunctionComponent<ChatbotHeaderMenuProps>
       <Button
         className="pf-chatbot__button--toggle-menu"
         variant="plain"
-        aria-describedby="pf-chatbot__tooltip--toggle-menu"
         onClick={onMenuToggle}
         aria-label={menuAriaLabel}
         icon={
diff --git a/packages/module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx b/packages/module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx
index 573f7039..6c6d714a 100644
--- a/packages/module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx
+++ b/packages/module/src/Message/CodeBlockMessage/CodeBlockMessage.tsx
@@ -54,7 +54,6 @@ const CodeBlockMessage = ({ children, className, ...props }: JSX.IntrinsicElemen
           aria-label="Copy code button"
           variant="plain"
           className="pf-chatbot__button--copy"
-          aria-describedby={tooltipID}
           onClick={(event) => handleCopy(event, children)}
         >
           {copied ? <CheckIcon /> : <CopyIcon />}
diff --git a/packages/module/src/MessageBar/AttachButton.tsx b/packages/module/src/MessageBar/AttachButton.tsx
index b4dd7f47..022c7b00 100644
--- a/packages/module/src/MessageBar/AttachButton.tsx
+++ b/packages/module/src/MessageBar/AttachButton.tsx
@@ -55,7 +55,6 @@ const AttachButtonBase: React.FunctionComponent<AttachButtonProps> = ({
           variant="plain"
           ref={innerRef}
           className={`pf-chatbot__button--attach ${className ?? ''}`}
-          aria-describedby="pf-chatbot__tooltip--attach"
           aria-label={props['aria-label'] || 'Attach Button'}
           isDisabled={isDisabled}
           onClick={onClick ?? open}
diff --git a/packages/module/src/MessageBar/MicrophoneButton.tsx b/packages/module/src/MessageBar/MicrophoneButton.tsx
index b52ae9af..5d5a9d30 100644
--- a/packages/module/src/MessageBar/MicrophoneButton.tsx
+++ b/packages/module/src/MessageBar/MicrophoneButton.tsx
@@ -95,7 +95,6 @@ export const MicrophoneButton: React.FunctionComponent<MicrophoneButtonProps> =
       <Button
         variant="plain"
         className={`pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${className ?? ''}`}
-        aria-describedby="pf-chatbot__tooltip--use-microphone"
         aria-label={props['aria-label'] || 'Microphone Button'}
         onClick={isListening ? stopListening : startListening}
         icon={
diff --git a/packages/module/src/MessageBar/SendButton.tsx b/packages/module/src/MessageBar/SendButton.tsx
index 7df352f1..7220a5a8 100644
--- a/packages/module/src/MessageBar/SendButton.tsx
+++ b/packages/module/src/MessageBar/SendButton.tsx
@@ -36,7 +36,6 @@ export const SendButton: React.FunctionComponent<SendButtonProps> = ({
     <Button
       className={`pf-chatbot__button--send ${className ?? ''}`}
       variant="link"
-      aria-describedby="pf-chatbot__tooltip--send"
       aria-label={props['aria-label'] || 'Send Button'}
       onClick={onClick}
       icon={
diff --git a/packages/module/src/MessageBox/JumpButton.tsx b/packages/module/src/MessageBox/JumpButton.tsx
index 6db83d17..00b1bf80 100644
--- a/packages/module/src/MessageBox/JumpButton.tsx
+++ b/packages/module/src/MessageBox/JumpButton.tsx
@@ -25,7 +25,6 @@ const JumpButton: React.FunctionComponent<JumpButtonProps> = ({ position, isHidd
         variant="plain"
         className={`pf-chatbot__jump pf-chatbot__jump--${position} ${isHidden && `pf-chatbot__jump--${position}--hidden`}`}
         aria-label={`Jump ${position} button`}
-        aria-describedby={`pf-chatbot__tooltip--jump-${position}`}
         onClick={onClick}
       >
         <Icon iconSize="xl" isInline>
diff --git a/packages/module/src/ResponseActions/ResponseActionButton.tsx b/packages/module/src/ResponseActions/ResponseActionButton.tsx
index 7997455c..e8db4f0a 100644
--- a/packages/module/src/ResponseActions/ResponseActionButton.tsx
+++ b/packages/module/src/ResponseActions/ResponseActionButton.tsx
@@ -2,7 +2,7 @@ import React from 'react';
 import { Button, Icon, Tooltip, TooltipProps } from '@patternfly/react-core';
 
 export interface ResponseActionButtonProps {
-  /** Aria-label for the button */
+  /** Aria-label for the button. Defaults to the value of the tooltipContent if none provided */
   ariaLabel?: string;
   /** Icon for the button */
   icon: React.ReactNode;
@@ -40,8 +40,7 @@ export const ResponseActionButton: React.FunctionComponent<ResponseActionButtonP
     <Button
       variant="plain"
       className={`pf-chatbot__button--response-action ${className ?? ''}`}
-      aria-describedby={`pf-chatbot__tooltip-response-action-${tooltipContent}`}
-      aria-label={ariaLabel}
+      aria-label={ariaLabel || tooltipContent}
       icon={
         <Icon isInline size="lg">
           {icon}