diff --git a/packages/core/src/components/field-wrapper/helper-text-util.tsx b/packages/core/src/components/field-wrapper/helper-text-util.tsx
index 0866535e8c4..a2a138e77d3 100644
--- a/packages/core/src/components/field-wrapper/helper-text-util.tsx
+++ b/packages/core/src/components/field-wrapper/helper-text-util.tsx
@@ -16,19 +16,31 @@ import {
export function hasAnyText({
invalidText,
+ isInvalid,
warningText,
+ isWarning,
infoText,
+ isInfo,
validText,
+ isValid,
helperText,
}: {
invalidText?: string;
+ isInvalid?: boolean;
warningText?: string;
+ isWarning?: boolean;
infoText?: string;
+ isInfo?: boolean;
validText?: string;
+ isValid?: boolean;
helperText?: string;
}) {
- return [invalidText, warningText, infoText, validText, helperText].some(
- (text) => text?.trim()
+ return (
+ (isInvalid && invalidText?.trim()) ||
+ (isWarning && warningText?.trim()) ||
+ (isInfo && infoText?.trim()) ||
+ (isValid && validText?.trim()) ||
+ helperText?.trim()
);
}
diff --git a/packages/core/src/components/field-wrapper/tests/field-wrapper.ct.ts b/packages/core/src/components/field-wrapper/tests/field-wrapper.ct.ts
index 6859564cf35..7758e67af38 100644
--- a/packages/core/src/components/field-wrapper/tests/field-wrapper.ct.ts
+++ b/packages/core/src/components/field-wrapper/tests/field-wrapper.ct.ts
@@ -200,3 +200,66 @@ regressionTest(
await expect(helperTextElement).toHaveCount(1);
}
);
+
+regressionTest(
+ 'should not show empty tooltip if invalidText is present but isInvalid is false and no helperText',
+ async ({ mount, page }) => {
+ await mount(
+ `
+
+ Content
+
+ `
+ );
+
+ const fieldWrapperElement = page.locator('ix-field-wrapper');
+ await expect(fieldWrapperElement).toHaveClass(/hydrated/);
+
+ const bottomTextElement = fieldWrapperElement
+ .locator('.field-bottom')
+ .locator('ix-typography.bottom-text');
+ await expect(bottomTextElement).toHaveCount(0);
+
+ await page.mouse.move(10, 10);
+ await page.waitForTimeout(500);
+
+ const tooltip = fieldWrapperElement.locator('ix-tooltip');
+ await expect(tooltip).toHaveCount(0);
+ await expect(tooltip).not.toBeVisible();
+ }
+);
+regressionTest(
+ 'should not show tooltip if invalidText is an empty string even when isInvalid is true',
+ async ({ mount, page }) => {
+ await mount(
+ `
+
+ Content
+
+ `
+ );
+ const fieldWrapperElement = page.locator('ix-field-wrapper');
+ await expect(fieldWrapperElement).toHaveClass(/hydrated/);
+
+ const bottomTextElement = fieldWrapperElement
+ .locator('.field-bottom')
+ .locator('ix-typography.bottom-text');
+ await expect(bottomTextElement).toHaveCount(0);
+
+ await page.mouse.move(10, 10);
+ await page.waitForTimeout(500);
+
+ const tooltip = fieldWrapperElement.locator('ix-tooltip');
+
+ await expect(tooltip).toHaveCount(0);
+ await expect(tooltip).not.toBeVisible();
+ }
+);