Skip to content

Commit

Permalink
Improve title of search validation icon (#20625)
Browse files Browse the repository at this point in the history
  • Loading branch information
grotlue authored Oct 8, 2024
1 parent 2d621be commit 1cecdf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SUTProps = {
}

describe('QueryValidation', () => {
const validationErrorIconTitle = 'Toggle validation error explanation';
const validationErrorIconTitle = /Toggle validation/;

const openExplanation = async () => {
const validationExplanationTrigger = await screen.findByTitle(validationErrorIconTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,25 @@ const QueryValidation = () => {
const hasExplanations = validationState && (validationState?.status !== 'OK');
const isInfo = validationState && (validationState.status === 'INFO');

const validationTitle = () => {
if (!validationState) return '';

switch (validationState.status) {
case 'WARNING':
return 'warning';
case 'INFO':
return 'information';
default:
return 'error explanation';
}
};

return (
<Popover opened={hasExplanations && showExplanation} position="bottom" width={500} withArrow>
<Popover.Target>
<Container ref={explanationTriggerRef}>
{hasExplanations ? (
<ExplanationTrigger title={`Toggle validation ${isInfo ? 'information' : 'error explanation'}`}
<ExplanationTrigger title={`Toggle validation ${validationTitle()}`}
onClick={toggleShow}
$clickable
tabIndex={0}
Expand Down

0 comments on commit 1cecdf1

Please sign in to comment.