Skip to content

Commit

Permalink
Merge pull request #228 from rebeccaalpert/a11y-214
Browse files Browse the repository at this point in the history
fix(Chatbot/JumpButton): Remove content from DOM when not visible
  • Loading branch information
nicolethoen authored Oct 14, 2024
2 parents 6652dc8 + 59cd014 commit 4bdcd2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/module/src/Chatbot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Chatbot: React.FunctionComponent<ChatbotProps> = ({
initial="hidden"
animate={isVisible ? 'visible' : 'hidden'}
>
{children}
{isVisible ? children : undefined}
</motion.div>
);
};
Expand Down
31 changes: 16 additions & 15 deletions packages/module/src/MessageBox/JumpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ export interface JumpButtonProps {
isHidden?: boolean;
}

const JumpButton: React.FunctionComponent<JumpButtonProps> = ({ position, isHidden, onClick }: JumpButtonProps) => (
<Tooltip id={`pf-chatbot__tooltip--jump-${position}`} content={`Back to ${position}`} position="top">
<Button
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>
{position === 'top' ? <ArrowUpIcon /> : <ArrowDownIcon />}
</Icon>
</Button>
</Tooltip>
);
const JumpButton: React.FunctionComponent<JumpButtonProps> = ({ position, isHidden, onClick }: JumpButtonProps) =>
isHidden ? undefined : (
<Tooltip id={`pf-chatbot__tooltip--jump-${position}`} content={`Back to ${position}`} position="top">
<Button
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>
{position === 'top' ? <ArrowUpIcon /> : <ArrowDownIcon />}
</Icon>
</Button>
</Tooltip>
);

export default JumpButton;

0 comments on commit 4bdcd2c

Please sign in to comment.