Skip to content

fix(core): size height calculation - #204

Merged
coryrylan merged 2 commits into
mainfrom
topic-input-style-fix
Aug 5, 2026
Merged

fix(core): size height calculation#204
coryrylan merged 2 commits into
mainfrom
topic-input-style-fix

Conversation

@coryrylan

@coryrylan coryrylan commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator
  • only set explicit computed height when size is applied, prevents specificity and rounding errors on standard single selects

Summary by CodeRabbit

  • New Features

    • Added content-based sizing for form controls using the fit-text variant.
    • Controls can expand or contract to match their content, including native date inputs.
  • Bug Fixes

    • Improved select component sizing behavior.
    • Preserved row-based height and border adjustments for sized select instances.
    • Improved fit-text sizing when content changes or the feature is disabled.

@coryrylan
coryrylan requested a review from johnyanarella July 31, 2026 20:41
@coryrylan coryrylan self-assigned this Jul 31, 2026
Copilot AI lite review requested due to automatic review settings July 31, 2026 20:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The select component now applies row-height and border calculations only in the size state. Control fit-text sizing now uses CSS content sizing instead of TypeScript width calculations. Tests validate rendered width changes and date input sizing.

Changes

Control and select sizing

Layer / File(s) Summary
Height and size-state rules
projects/core/src/select/select.css
--_height defaults to --height. The size state applies row-height and border calculations.
CSS-based fit-text sizing
projects/core/src/forms/control/control.css, projects/core/src/forms/control/control.ts, projects/core/src/forms/control/control.test.ts, projects/core/src/forms/input/input.css
The fit-text variant uses field-sizing: content and fit-content widths. TypeScript sizing listeners and calculations are removed. Tests validate rendered width changes and date input sizing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: scope(core)

Suggested reviewers: johnyanarella

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change to core height sizing and matches the stated pull request objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch topic-input-style-fix

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/core/src/select/select.css`:
- Line 26: Add regression assertions in the select tests covering computed
height for a default single-select, a sized select, and after clearing size.
Extend the existing :state(size)/--size coverage near the referenced select test
cases, verifying both the --height fallback and the row/gap/border calculation
paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: fcf7a93d-1545-4133-89d0-67cca415c785

📥 Commits

Reviewing files that changed from the base of the PR and between 651abf3 and b62dfa7.

📒 Files selected for processing (1)
  • projects/core/src/select/select.css

Comment thread projects/core/src/select/select.css
@coryrylan
coryrylan force-pushed the topic-input-style-fix branch from b62dfa7 to c174663 Compare July 31, 2026 20:54
Copilot AI review requested due to automatic review settings July 31, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 4, 2026 14:48
@coryrylan
coryrylan force-pushed the topic-input-style-fix branch from c174663 to 3f104f0 Compare August 4, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 4, 2026 23:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@projects/core/src/forms/control/control.test.ts`:
- Around line 272-305: Add a test alongside the existing fit-text sizing cases
that exercises a select element and asserts its rendered width changes when the
selected content or available options change. Reuse the existing control setup
and stabilization/animation-frame waits, and verify the select’s measured width
before and after the change to cover the field-sizing behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: cca8720c-f81b-4c22-a3e3-339eea9bead9

📥 Commits

Reviewing files that changed from the base of the PR and between 3f104f0 and 5bc62fd.

⛔ Files ignored due to path filters (2)
  • projects/core/.visual/toolbar.dark.png is excluded by !**/*.png
  • projects/core/.visual/toolbar.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • projects/core/src/forms/control/control.css
  • projects/core/src/forms/control/control.test.ts
  • projects/core/src/forms/control/control.ts
  • projects/core/src/input/input.css
💤 Files with no reviewable changes (2)
  • projects/core/src/input/input.css
  • projects/core/src/forms/control/control.ts

Comment thread projects/core/src/forms/control/control.test.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (3)

projects/core/src/forms/control/control.css:64

  • The new :host([fit-text]) { ::slotted(...) { ... } } block relies on CSS nesting. If nesting isn’t consistently supported/processed in this repo’s CSS pipeline, the inner rule will be ignored and fit-text won’t apply. Prefer explicit selectors (and optionally guard field-sizing behind @supports) to make the styling unambiguous.
:host([fit-text]) {
  --max-width: fit-content;
  --width: fit-content;

  ::slotted(input),
  ::slotted(select) {
    field-sizing: content;
  }
}

projects/core/src/forms/control/control.ts:183

  • This PR is titled/described as a select size height calculation fix, but it also removes the fit-text runtime sizing logic from Control (and derived components like nve-input/nve-select) and rewrites the related unit tests. That’s a behavior/API change beyond the stated scope, so it should either be called out in the PR description/release notes or split into a separate PR to keep the change focused.
  #onRootSlotchange = () => {
    this.#updateStyleStates();

    if (this.input && this.#observers.length === 0) {
      this.#setupInput();
    }

projects/core/src/forms/control/control.test.ts:336

  • The dedicated fit-text select unit tests were removed. Since fit-text is still documented/implemented for select (via ::slotted(select) styling), this reduces coverage for a supported code path and makes regressions harder to catch. Consider restoring equivalent assertions (or adding new ones that validate nve-select fit-text behavior) so both input and select are exercised.
describe(`${Control.metadata.tag}: fit-content input`, () => {
  let fixture: HTMLElement;
  let element: Control;
  let input: HTMLInputElement;

  beforeEach(async () => {
    fixture = await createFixture(html`
      <nve-control fit-content>
        <label>label</label>
        <input type="text" />
      </nve-control>
    `);
    element = fixture.querySelector(Control.metadata.tag);
    input = fixture.querySelector('input');
    await elementIsStable(element);
  });

  afterEach(() => {
    removeFixture(fixture);
  });

  it('should update control width to input browser default content', async () => {
    await elementIsStable(element);
    await new Promise(r => requestAnimationFrame(r));
    expect(Math.floor(input.getBoundingClientRect().width) > 100).toBe(true);
    expect(Math.floor(input.getBoundingClientRect().width) < 250).toBe(true);
  });
});

- only set explicit computed height when size is applied, prevents specificity and rounding errors on standard single selects

Signed-off-by: Cory Rylan <crylan@nvidia.com>
Copilot AI review requested due to automatic review settings August 5, 2026 15:59
@coryrylan
coryrylan force-pushed the topic-input-style-fix branch from 5bc62fd to 4d1c61f Compare August 5, 2026 15:59
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (2)

projects/core/src/forms/control/control.css:64

  • fit-text relies on field-sizing: content, but several components (e.g. nve-input and nve-select) set ::slotted(input/select) { width: 100% !important; }, which prevents content-based sizing from taking effect. Consider overriding the slotted control width (and --control-width) within the :host([fit-text]) rule so field-sizing can actually influence layout.
:host([fit-text]) {
  --max-width: fit-content;
  --width: fit-content;

  ::slotted(input),

projects/core/src/forms/control/control.test.ts:280

  • The previous fit-text select coverage was removed, but fit-text is still expected to apply to <select> (Control CSS now targets ::slotted(select)). With no remaining unit coverage for the select case, regressions (especially around select sizing) are unlikely to be caught. Consider adding at least one deterministic test for the select path (e.g., asserting a measurable width change between two option labels, or asserting the field-sizing computed style when supported).
  it('should set input width to text content width', async () => {
    await new Promise(resolve => requestAnimationFrame(resolve));
    const fitTextWidth = input.getBoundingClientRect().width;

    element.fitText = false;
    await elementIsStable(element);
    await new Promise(resolve => requestAnimationFrame(resolve));

    expect(fitTextWidth).toBeLessThan(input.getBoundingClientRect().width);

Signed-off-by: Cory Rylan <crylan@nvidia.com>
Copilot AI review requested due to automatic review settings August 5, 2026 17:23
@coryrylan
coryrylan force-pushed the topic-input-style-fix branch from 4d1c61f to 9ab9bca Compare August 5, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@coryrylan
coryrylan merged commit cadc33c into main Aug 5, 2026
16 checks passed
@coryrylan
coryrylan deleted the topic-input-style-fix branch August 5, 2026 21:45
@coryrylan

Copy link
Copy Markdown
Collaborator Author

🎉 This issue has been resolved in version 2.2.3 🎉

Changelog

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants