Skip to content

fix(NcSelect): floating label design using NcTextField#8570

Open
skjnldsv wants to merge 1 commit into
mainfrom
fix/ncselect-design
Open

fix(NcSelect): floating label design using NcTextField#8570
skjnldsv wants to merge 1 commit into
mainfrom
fix/ncselect-design

Conversation

@skjnldsv

@skjnldsv skjnldsv commented May 26, 2026

Copy link
Copy Markdown
Contributor

☑️ Resolves

  • Relates to nextcloud-libraries/nextcloud-vue#8XXX (NcSelect visual alignment with other form fields)

Summary

Replace the plain <input> in NcSelect's #search slot with NcTextField so the component shares the same floating label, border, and focus styling as NcTextField and NcTextArea.

Single mode:

  • NcTextField owns the border and floating label
  • Selected value overlays the input (position: absolute, z-index: 2)
  • Label floats on focus or when value selected via :has(.vs__selected)
  • Extra padding when clearable (clear + chevron need space)

Multi mode:

  • Border on .vs__dropdown-toggle (contains tags + search input)
  • Floating label via #header slot, centered when empty, floats on border when tags present or dropdown open
  • Search input inline with tags (flex-grow, no layout jump on open)
  • Tags clipped before actions via max-width in no-wrap mode

Drop-up:

  • Border/radius inverted (transparent top, rounded bottom)
  • Label moves to bottom border

CSS scoping:

  • data-v-new-select attribute on root element for manual scoping
  • CSS variables scoped to [data-v-new-select].v-select.select
  • Dropdown menu variables set directly on .vs__dropdown-menu (teleported to body by floating-ui)
  • inputLikeBorder mixin inlined to fix @media #{&} doubled-selector bug
  • Dark/light theme border overrides with correct selectors

Other:

  • Forward vue-select events (keydown, blur, focus, IME) via filterEvents()
  • v-bind before explicit props (Vue 3 last-binding-wins)
  • No placeholder when multi or value selected (avoids overlap)
  • Disabled state: transparent backgrounds, lighter border via --color-border-dark

Tests added:

  • 17 unit tests (vitest): label, placeholder, disabled, inputClass, modelValue, required, single/multi mode, labelOutside, accessibility warnings, event forwarding
  • 24 component tests (Playwright): open/close, keyboard nav, search/filter, select, multi tags, deselect, Tab/Escape/blur close, e2e flows

Docs added:

  • Pre-selected and clearable example
  • Disabled state example (single + multi)
  • Label outside example (single + multi)

🖼️ Screenshots

🏚️ Before 🏡 After
image image
image image
2026-06-03_17-01_1 2026-06-03_17-01

🚧 Tasks

  • NcTextField integration in search slot
  • Event forwarding (keydown, blur, focus, IME)
  • Single mode selected value positioning
  • Multi mode tags inside bordered container
  • Floating label when value selected
  • Open state / drop-up border-radius + label repositioning
  • CSS scoping via data-v-new-select
  • Dark theme border fix (inlined mixin)
  • Disabled state styling
  • No-wrap overflow clipping
  • Unit tests (17)
  • Component/e2e tests (24)
  • Documentation examples (3 new sections)

🏁 Checklist

  • ⛑️ Tests are included (17 unit + 24 Playwright component tests)
  • 📘 Component documentation has been extended (3 new example sections)
  • 2️⃣ Backport to stable8 for maintained Vue 2 version or not applicable

@skjnldsv skjnldsv added enhancement New feature or request 2. developing Work in progress labels May 26, 2026
@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.28%. Comparing base (034beb5) to head (e8979d2).
⚠️ Report is 128 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8570      +/-   ##
==========================================
+ Coverage   54.55%   55.28%   +0.73%     
==========================================
  Files         106      106              
  Lines        3439     3451      +12     
  Branches     1002     1008       +6     
==========================================
+ Hits         1876     1908      +32     
+ Misses       1322     1308      -14     
+ Partials      241      235       -6     

☔ 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.

@skjnldsv skjnldsv self-assigned this May 26, 2026
@skjnldsv skjnldsv added bug Something isn't working feature: select Related to the NcSelect* components labels May 26, 2026
@ShGKme ShGKme added this to the 9.8.1 milestone May 26, 2026
@skjnldsv skjnldsv force-pushed the fix/ncselect-design branch 2 times, most recently from 54aa738 to 86ca380 Compare May 27, 2026 13:39
@skjnldsv skjnldsv requested review from Copilot and susnux May 27, 2026 13:48
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels May 27, 2026
@skjnldsv skjnldsv requested review from hamza221, jancborchardt, kra-mo and marcoambrosini and removed request for Copilot May 27, 2026 13:48
@skjnldsv skjnldsv force-pushed the fix/ncselect-design branch 2 times, most recently from 2f91d67 to e9d00bd Compare May 27, 2026 14:44
jancborchardt

This comment was marked as resolved.

@skjnldsv

This comment was marked as resolved.

kra-mo

This comment was marked as resolved.

@kra-mo

This comment was marked as resolved.

@kra-mo

This comment was marked as resolved.

@skjnldsv skjnldsv force-pushed the fix/ncselect-design branch 16 times, most recently from b6c2cd5 to 5445b57 Compare June 3, 2026 14:59
@skjnldsv skjnldsv requested review from jancborchardt and kra-mo June 3, 2026 15:00
@skjnldsv

skjnldsv commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Ok @kra-mo @jancborchardt seems I fixed it all! Please update your reviews 🙇

@skjnldsv skjnldsv force-pushed the fix/ncselect-design branch 2 times, most recently from 2e74a7f to fc5d953 Compare June 4, 2026 07:35
Replace the plain `<input>` in NcSelect's search slot with NcTextField
to get consistent floating label, border, and focus styling across all
form fields.

Single mode:
- NcTextField owns the border and floating label
- Selected value overlays the input (position: absolute, z-index: 2)
- Label floats on focus or when value selected via :has(.vs__selected)

Multi mode:
- Border on .vs__dropdown-toggle (contains tags + search input)
- Floating label via #header slot, centered when empty, floats on
  border when tags present or dropdown open
- Search input inline with tags (flex-grow, no layout jump on open)
- Tags hidden behind actions prevented via padding-inline-end

Drop-up:
- Border/radius inverted (transparent top, rounded bottom)
- Label moves to bottom border

Other fixes:
- Forward vue-select events (keydown, blur, focus, IME) via
  filterEvents() to reach the native <input>
- Scope CSS variables to .v-select.select (not body)
- Dropdown menu variables set directly (teleported to body by
  floating-ui, can't inherit from .v-select.select)
- Inline inputLikeBorder mixin to fix @media doubled-selector bug
- Dark/light theme border overrides with correct selectors
- No-wrap overflow clips before actions area

Signed-off-by: skjnldsv <skjnldsv@users.noreply.github.com>
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv force-pushed the fix/ncselect-design branch from fc5d953 to e8979d2 Compare June 4, 2026 12:20
@kra-mo

kra-mo commented Jun 4, 2026

Copy link
Copy Markdown
Member

Looks mostly OK, but

  1. user select seems to still clip for me
image

and

  1. I'm not loving the label shifting to the bottom:
image

Any chance to just make some room for it and keep it at the same spot even when it expands above?

@kra-mo

kra-mo commented Jun 4, 2026

Copy link
Copy Markdown
Member

Oof, and also, the previous selection remains as a placeholder and you can type over it?

image

And in general the selected value is misaligned with the actual thing you're typing so the position marker clips:

image

@skjnldsv

skjnldsv commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm definitely missing my last commit because those are 3 issues I fixed thhis morning 🙈
Il'l have a look at my laptop

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

Labels

3. to review Waiting for reviews bug Something isn't working enhancement New feature or request feature: select Related to the NcSelect* components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants