Skip to content

feat: Add inlineLabelText to input - #4956

Open
jperals wants to merge 6 commits into
mainfrom
feat/input-inline-label
Open

feat: Add inlineLabelText to input#4956
jperals wants to merge 6 commits into
mainfrom
feat/input-inline-label

Conversation

@jperals

@jperals jperals commented Sep 1, 2026

Copy link
Copy Markdown
Member

Description

Required for control group feature (doc: dwYUc9i8X0rP, draft PR: #4969)

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.66%. Comparing base (dec0201) to head (d7b73ea).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4956   +/-   ##
=======================================
  Coverage   97.66%   97.66%           
=======================================
  Files         959      959           
  Lines       31342    31350    +8     
  Branches    11577    11580    +3     
=======================================
+ Hits        30611    30619    +8     
+ Misses        724      685   -39     
- Partials        7       46   +39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

expect(element).not.toHaveAttribute('aria-invalid');
});

test('renders inline label when __inlineLabelText is provided', () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Consolidated input inline label tests into the new file src/input/__tests__/inline-label.test.tsx

Comment thread src/input/interfaces.ts
style?: InputProps.Style;

/**
* Adds a small label inline with the input for saving vertical space in the UI.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Based on Select API doc text:

* Adds a small label inline with the input for saving vertical space in the UI.

Comment thread src/input/internal.tsx
/>
);

const inputWithLabel = __inlineLabelText ? (

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To support the combination of inline label + suffix/prefix, the input with suffix/prefix needs to be rendered inside and a container with the label outside, not the other way around. This is what these changes do.

@jperals
jperals marked this pull request as ready for review September 3, 2026 09:30
@jperals
jperals requested a review from a team as a code owner September 3, 2026 09:30
@jperals
jperals requested review from avinashbot and vvaliyev and a lite review from Copilot and removed request for a team September 3, 2026 09:30

Copilot AI left a comment

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.

🟡 Changes recommended

The inline <label htmlFor> can become desynchronized from the native input id when nativeInputAttributes.id is used, which breaks label association.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a new public inlineLabelText API for the Input component to support inline labels (useful for space-constrained UIs), and updates internal consumers and tests accordingly.

Changes:

  • Add inlineLabelText?: string to InputProps and plumb it through InputInternalInput.
  • Update InternalInput rendering to support an inline <label> (including generated controlId when needed) and add a disabled inline-label style.
  • Add dedicated unit coverage + a permutations page for visual/regression review; update Pagination to use the new prop.
File summaries
File Description
src/test-utils/dom/input/index.ts Adds findInlineLabel() test-utils helper for the new inline label element.
src/pagination/internal.tsx Switches jump-to-page input to use the new public inlineLabelText prop.
src/input/styles.scss Adds disabled styling hook for the inline label.
src/input/internal.tsx Implements inline label rendering, generated IDs, and adjusts root vs container prop application.
src/input/interfaces.ts Exposes inlineLabelText on the public InputProps API with documentation.
src/input/index.tsx Passes inlineLabelText through to the internal implementation.
src/input/tests/internal.test.tsx Removes legacy tests tied to the private __inlineLabelText prop.
src/input/tests/inline-label.test.tsx Adds unit tests for inlineLabelText behavior and ID/label association.
src/tests/snapshot-tests/snapshots/test-utils-selectors.test.tsx.snap Updates selector snapshots for the new inline label selector.
src/tests/snapshot-tests/snapshots/documenter.test.ts.snap Updates generated API/test-utils documentation snapshots for the new prop/helper.
pages/input/inline-label-permutations.page.tsx Adds a permutations page to manually verify inline-label rendering combinations.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/input/internal.tsx
Comment thread src/input/__tests__/inline-label.test.tsx
jperals and others added 2 commits September 3, 2026 15:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants