diff --git a/.storybook/snapshots/__snapshots__/generativedirectanswer--primary.png b/.storybook/snapshots/__snapshots__/generativedirectanswer--primary.png index 55c6daed..d7e44aba 100644 Binary files a/.storybook/snapshots/__snapshots__/generativedirectanswer--primary.png and b/.storybook/snapshots/__snapshots__/generativedirectanswer--primary.png differ diff --git a/docs/search-ui-react.aisignpostprops.label.md b/docs/search-ui-react.aisignpostprops.label.md index 8b271783..346f9070 100644 --- a/docs/search-ui-react.aisignpostprops.label.md +++ b/docs/search-ui-react.aisignpostprops.label.md @@ -4,7 +4,7 @@ ## AISignpostProps.label property -Label displayed in the signpost button. Defaults to "AI-Generated". +Label displayed in the signpost button. **Signature:** diff --git a/docs/search-ui-react.aisignpostprops.md b/docs/search-ui-react.aisignpostprops.md index 3894c588..522f6069 100644 --- a/docs/search-ui-react.aisignpostprops.md +++ b/docs/search-ui-react.aisignpostprops.md @@ -69,7 +69,7 @@ string -_(Optional)_ Label displayed in the signpost button. Defaults to "AI-Generated". +_(Optional)_ Label displayed in the signpost button. diff --git a/package-lock.json b/package-lock.json index 6009d38c..eac023aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@yext/search-ui-react", - "version": "3.1.0", + "version": "3.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@yext/search-ui-react", - "version": "3.1.0", + "version": "3.1.1", "license": "BSD-3-Clause", "dependencies": { "@restart/ui": "^1.0.1", diff --git a/package.json b/package.json index 770db791..d3d8a5db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/search-ui-react", - "version": "3.1.0", + "version": "3.1.1", "description": "A library of React Components for powering Yext Search integrations", "author": "watson@yext.com", "license": "BSD-3-Clause", diff --git a/src/components/GenerativeDirectAnswer.tsx b/src/components/GenerativeDirectAnswer.tsx index 99d2cf15..15455f2e 100644 --- a/src/components/GenerativeDirectAnswer.tsx +++ b/src/components/GenerativeDirectAnswer.tsx @@ -14,6 +14,7 @@ import { AISignpostIcon } from '../icons/AISignpostIcon'; import { CloseIcon } from '../icons/CloseIcon'; import { Markdown, MarkdownCssClasses } from './Markdown'; import { useId } from '../hooks/useId'; +import { twMerge } from '../hooks/useComposedCssClasses'; import React, { useCallback, useMemo, useRef } from 'react'; /** @@ -159,7 +160,7 @@ interface AnswerProps { export interface AISignpostProps { /** Icon displayed before the signpost label. Defaults to the SDK's AI signpost icon. */ icon?: React.JSX.Element, - /** Label displayed in the signpost button. Defaults to "AI-Generated". */ + /** Label displayed in the signpost button. */ label?: string, /** Header displayed in the signpost popover. Defaults to "AI-Generated Content". */ popoverHeader?: string, @@ -181,6 +182,7 @@ function AISignpost({ const popoverId = useId('ai-signpost-popover'); const popoverHeaderId = useId('ai-signpost-popover-header'); const popoverDescriptionId = useId('ai-signpost-popover-description'); + const ariaLabel = label ?? t('aiGeneratedAnswerSignpostLabel'); const handleSignpostClick = useCallback(() => { setIsOpen(current => !current); }, []); @@ -189,16 +191,17 @@ function AISignpost({ }, []); return ( -
+
{isOpen && (
@@ -259,10 +262,10 @@ function Answer(props: AnswerProps) { }, [linkClickHandler]); return <> -
- {answerHeader ?? t('aiGeneratedAnswer')} +
+
{answerHeader ?? t('aiGeneratedAnswer')}
+ {!hideAISignpost && }
- {!hideAISignpost && } { mockAnswersState(mockedState); }); - it('displays the default AI signpost below the answer header', () => { + it('displays the default AI signpost next to the answer header', () => { render(); const answerHeader = screen.getByText('AI Generated Answer'); @@ -161,7 +161,7 @@ describe('GenerativeDirectAnswer with sufficient citation fields', () => { />); expect(screen.getByTestId('custom-ai-signpost-icon')).toBeTruthy(); - await userEvent.click(screen.getByRole('button', { name: 'Custom Icon Custom Label' })); + await userEvent.click(screen.getByRole('button', { name: 'Custom Label' })); expect(screen.getByRole('dialog', { name: 'Custom Header' })).toBeTruthy(); expect(screen.getByText('Custom Body')).toBeTruthy();