Skip to content

[WC-3409] Combobox: prevent 1px collapse#2237

Open
yordan-st wants to merge 1 commit into
mendix:mainfrom
yordan-st:fix/WC-3409_combobox-bug
Open

[WC-3409] Combobox: prevent 1px collapse#2237
yordan-st wants to merge 1 commit into
mendix:mainfrom
yordan-st:fix/WC-3409_combobox-bug

Conversation

@yordan-st
Copy link
Copy Markdown
Contributor

@yordan-st yordan-st commented May 29, 2026

Summary

  • Fixes WC-3409: Combobox collapses to 1px when placed in a flex row container with align-items: center
  • Root cause: Mendix injects .form-group.no-columns (column flex, no explicit width) between the user's container and .widget-combobox. flex-grow: 1 distributes height in a column container, not width. Children suppress min-width to ~0 via min-width: 0 on .widget-combobox-selected-items (intentional, needed for multiselect tag wrapping)
  • Fix: min-width: 15ch on .widget-combobox — explicit value does not ask children, breaking the collapse chain. ch scales with font-size rather than using px

Changes

  • src/ui/Combobox.scssmin-width: 15ch on .widget-combobox root rule
  • src/__tests__/ComboboxStyles.spec.ts — unit test updated to assert 15ch
  • e2e/Combobox.spec.js — E2E regression tests added (pending Studio Pro test page at /p/combobox-flex-layout)
  • openspec/changes/fix-combobox-flex-collapse/ — design artifacts with corrected root cause analysis

Test plan

  1. Create a new page in Studio Pro with a container whose CSS class applies display: flex; flex-flow: row; align-items: center (e.g. add a class row-center and define it in a custom stylesheet).
  2. Place a Combobox widget (single-select, connected to any enumeration attribute) inside that container.
  3. Run the app locally and open the page.
  4. Before the fix: the combobox is invisible (collapses to ~1px width). After the fix: the combobox renders with a visible width (≥ 15ch).
  5. Repeat steps 1–4 with a multi-select Combobox to confirm the same result.
  6. Verify that typing in the combobox input and selecting a value still works normally.

Override

To restore previous behavior: .widget-combobox { min-width: 0; } in app CSS.

@yordan-st yordan-st requested a review from a team as a code owner May 29, 2026 14:35
@yordan-st yordan-st closed this May 29, 2026
@yordan-st yordan-st reopened this May 29, 2026
@yordan-st yordan-st force-pushed the fix/WC-3409_combobox-bug branch from afca5ab to 84a04df Compare May 29, 2026 14:59
@yordan-st yordan-st changed the title fix(combobox): prevent collapse to 1px in flex align-items:center containers [WC-3409] Combobox: prevent 1px collapse Jun 1, 2026
const scss = readFileSync(join(__dirname, "../ui/Combobox.scss"), "utf-8");

describe("Combobox SCSS — flex collapse fix (WC-3409)", () => {
test(".widget-combobox has min-width: 15ch", () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Testing what is in the CSS file feels over the top.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, redundant

└─ .widget-combobox-input (max-width:0 unfocused, width:1px multiselect inactive)
```

The user created `.row-center`. Mendix injected `.form-group.no-columns` as an intermediate wrapper. That wrapper has no explicit width and becomes a column-direction flex container. Inside it, `flex-grow:1` on `.widget-combobox` distributes height, not width. The widget's width is sized by content, and `min-width: min-content` resolves to ~0 because `.widget-combobox-selected-items` has `min-width: 0` (needed for multiselect tag wrapping).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How other input widgets, like text box handle this? Maybe atlas has to be fixed instead of it has to be a combination of fixes in two places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Investigated further. Atlas's min-width: 50px on .form-control does reach the combobox but 50px is too small. Therefore it seems collapsed.

What should the correct minimum be in Atlas? My widget-level fix used 15ch (~160px at default font) which felt reasonable for a text input. Happy to implement whatever value makes sense for atlas. just need a steer on the number.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should fix it in the .form-control level, override this 50px with a value that is more applicable to combobox. So inputs behave consistently.


`packages/pluggableWidgets/combobox-web/src/ui/Combobox.scss` — `.widget-combobox` rule (line 21).

Replace `min-width: min-content` with `min-width: 15ch`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It as 0, not min-content if I see correctly.


The user created `.row-center`. Mendix injected `.form-group.no-columns` as an intermediate wrapper. That wrapper has no explicit width and becomes a column-direction flex container. Inside it, `flex-grow:1` on `.widget-combobox` distributes height, not width. The widget's width is sized by content, and `min-width: min-content` resolves to ~0 because `.widget-combobox-selected-items` has `min-width: 0` (needed for multiselect tag wrapping).

`min-width: 15ch` is an explicit value — it does not ask children, so the children's suppressed minimums are irrelevant.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why 15, and not 5 or 42?

Copy link
Copy Markdown
Contributor Author

@yordan-st yordan-st Jun 3, 2026

Choose a reason for hiding this comment

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

A too small value like 5 or to high like 42 would make it too narrow or wide in most cases. Thought 15 is a general sweet spot, considering the average font size.

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.

2 participants