Skip to content

feat(TextArea): enable errorplacement prop ISSUE-2270#2689

Open
KrotovPetr wants to merge 2 commits into
mainfrom
ISSUE-2270.text-area2
Open

feat(TextArea): enable errorplacement prop ISSUE-2270#2689
KrotovPetr wants to merge 2 commits into
mainfrom
ISSUE-2270.text-area2

Conversation

@KrotovPetr
Copy link
Copy Markdown
Contributor

@KrotovPetr KrotovPetr commented May 22, 2026

#2270

Summary by Sourcery

Add support for placing TextArea validation errors inside the control via an icon tooltip and update styles, tests, and docs accordingly.

New Features:

  • Introduce the errorPlacement prop for TextArea to render validation errors either outside or inside the control via an error icon tooltip.

Documentation:

  • Document the new TextArea errorPlacement prop, its default behavior, and add examples for inside error placement.

Tests:

  • Extend TextArea unit and visual tests to cover the new errorPlacement options, including inside placement with and without a clear button.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 22, 2026

Reviewer's Guide

Implements an errorPlacement prop for TextArea that allows rendering validation errors either outside (existing behavior) or inside the control as an error icon with tooltip, updates layout/styles to coexist with the clear button and scrollbars, and extends tests, stories, and docs accordingly.

File-Level Changes

Change Details Files
Add inside error placement option rendering an inline error icon with tooltip while preserving default outside error message behavior.
  • Extend TextArea props and errorPropsMapper usage to accept an errorPlacement prop defaulting to 'outside'.
  • Derive isErrorMsgVisible and isErrorIconVisible flags based on validationState, errorMessage, and errorPlacement.
  • Render a Popover-wrapped TriangleExclamation Icon inside the control when errorPlacement is 'inside', wiring QA data attributes for testing.
  • Pass a 'has-error-icon' modifier to the BEM class builder to drive conditional styling.
  • Update README and Storybook showcase to document and demonstrate inside error placement and add it to the public API table.
src/components/controls/TextArea/TextArea.tsx
src/components/controls/TextArea/README.md
src/components/controls/TextArea/__stories__/TextAreaShowcase.tsx
Adjust TextArea layout and spacing to support an inline error icon alongside the clear button and scrollbars across sizes.
  • Introduce error-icon and error-icon-wrap BEM elements with absolute positioning controlled via CSS custom properties.
  • For each size variant (s, m, l, xl), share padding rules between has-clear and has-error-icon and add combined rules when both are present to increase right padding.
  • Define per-size CSS variables for error icon inline/block offsets to align the icon visually in the control.
  • Handle scrollbar presence by shifting the error icon wrapper similarly to the clear button and add combined has-clear+has-error-icon rules to avoid overlap when scrollbars exist.
src/components/controls/TextArea/TextArea.scss
Expand unit and visual tests and test cases to cover inside error placement behavior.
  • Add errorPlacementCases to the shared test cases and pass them into the visual tests matrix so both inside and outside placements are captured.
  • Add visual smoke tests ensuring the inside error tooltip appears on hover and renders correctly with and without the clear button.
  • Add unit tests verifying that an error icon is rendered only when errorPlacement is 'inside' with non-empty error/errorMessage and validationState='invalid', and that no icon is shown for empty error texts.
src/components/controls/TextArea/__tests__/TextArea.visual.test.tsx
src/components/controls/TextArea/__tests__/TextArea.test.tsx
src/components/controls/TextArea/__tests__/cases.tsx

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui
Copy link
Copy Markdown
Contributor

gravity-ui Bot commented May 22, 2026

Preview is ready.

@gravity-ui
Copy link
Copy Markdown
Contributor

gravity-ui Bot commented May 22, 2026

🎭 Component Tests Report is ready.

@KrotovPetr KrotovPetr marked this pull request as ready for review May 22, 2026 11:45
@KrotovPetr KrotovPetr requested a review from korvin89 as a code owner May 22, 2026 11:45
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new inside error icon/tooltip flow doesn’t appear to expose the error text to assistive technologies (no aria-describedby from the textarea and no ARIA attributes on the icon/tooltip), so consider wiring the tooltip content into the existing accessibility path used for outside errors to keep the control screen‑reader friendly.
  • The error icon trigger is currently a plain <span> inside a Popover; consider giving it a semantic role (e.g., role="button" and tabIndex=0, or making it purely decorative and reflecting the error on the textarea itself) so keyboard users can reliably access the tooltip or aren’t required to interact with it.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new inside error icon/tooltip flow doesn’t appear to expose the error text to assistive technologies (no `aria-describedby` from the textarea and no ARIA attributes on the icon/tooltip), so consider wiring the tooltip content into the existing accessibility path used for outside errors to keep the control screen‑reader friendly.
- The error icon trigger is currently a plain `<span>` inside a `Popover`; consider giving it a semantic role (e.g., `role="button"` and `tabIndex=0`, or making it purely decorative and reflecting the error on the textarea itself) so keyboard users can reliably access the tooltip or aren’t required to interact with it.

## Individual Comments

### Comment 1
<location path="src/components/controls/TextArea/__tests__/TextArea.visual.test.tsx" line_range="124" />
<code_context>
     });
+
+    test(
+        'smoke inside error placement tooltip',
+        {tag: ['@smoke']},
+        async ({mount, page, expectScreenshot}) => {
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen the smoke tooltip test by asserting the tooltip content text, not just visibility

Right now the test only checks that `.g-popup` becomes visible after hovering the error icon, so it won’t catch cases where the tooltip shows the wrong text. Please also assert that the popup contains `Test error message` (or at least the `errorMessage` prop value) to better guard against regressions in tooltip content.

Suggested implementation:

```typescript
        'smoke inside error placement tooltip',
        {tag: ['@smoke']},
        async ({mount, page, expectScreenshot}) => {
            const props: TextAreaProps = {
                ...defaultProps,
                value: 'Text',
                validationState: 'invalid',
                errorMessage: 'Test error message',
                errorPlacement: 'inside',
            };

            const root = await mount(
                <div style={{width: 250}}>

```

```typescript
        const popup = page.locator('.g-popup');
        await expect(popup).toBeVisible();
        await expect(popup).toContainText('Test error message');

```

If the test currently uses a different selector or assertion for the tooltip (for example, a more specific locator than `.g-popup`, or `toHaveText` instead of `toBeVisible`), adapt the `popup` locator and the added `toContainText('Test error message')` call accordingly.  
If `errorMessage` is changed in this test in the future, consider asserting `props.errorMessage` instead of the literal string to keep the test in sync:
```ts
await expect(popup).toContainText(props.errorMessage);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

});

test(
'smoke inside error placement tooltip',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Strengthen the smoke tooltip test by asserting the tooltip content text, not just visibility

Right now the test only checks that .g-popup becomes visible after hovering the error icon, so it won’t catch cases where the tooltip shows the wrong text. Please also assert that the popup contains Test error message (or at least the errorMessage prop value) to better guard against regressions in tooltip content.

Suggested implementation:

        'smoke inside error placement tooltip',
        {tag: ['@smoke']},
        async ({mount, page, expectScreenshot}) => {
            const props: TextAreaProps = {
                ...defaultProps,
                value: 'Text',
                validationState: 'invalid',
                errorMessage: 'Test error message',
                errorPlacement: 'inside',
            };

            const root = await mount(
                <div style={{width: 250}}>
        const popup = page.locator('.g-popup');
        await expect(popup).toBeVisible();
        await expect(popup).toContainText('Test error message');

If the test currently uses a different selector or assertion for the tooltip (for example, a more specific locator than .g-popup, or toHaveText instead of toBeVisible), adapt the popup locator and the added toContainText('Test error message') call accordingly.
If errorMessage is changed in this test in the future, consider asserting props.errorMessage instead of the literal string to keep the test in sync:

await expect(popup).toContainText(props.errorMessage);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant