Skip to content

feat(form): show value-map options as chip buttons when ≤ 4 choices#4391

Open
saberraz wants to merge 2 commits intomasterfrom
feature/chip-selector-for-short-value-maps
Open

feat(form): show value-map options as chip buttons when ≤ 4 choices#4391
saberraz wants to merge 2 commits intomasterfrom
feature/chip-selector-for-short-value-maps

Conversation

@saberraz
Copy link
Contributor

@saberraz saberraz commented Mar 16, 2026

Value-map fields with 4 or fewer options now render all choices as inline pill/chip buttons directly on the form, eliminating the need to open a drawer for short lists (e.g. a 4-value condition rating).

Fields with 5 or more options continue to use the existing dropdown drawer (MMFormComboboxBaseEditor + MMListMultiselectDrawer) unchanged, so there is no regression for longer lists.

Implementation
• New MMFormChipEditor.qml (extends MMBaseInput):

Displays options as a horizontally-wrapping Flow of pill Rectangles.
Selected chip: grassColor (#73D19C) background.
Unselected chip: white background with forestColor border.
Read-only state: MouseArea disabled, chips still visible.
Emits editorValueChanged / rememberValueBoxClicked for MMFormPage compatibility.
• Refactored MMFormValueMapEditor.qml (now an Item wrapper):

Parses _fieldConfig into a shared ListModel in Component.onCompleted.
After parsing, sets _modelReady = true which triggers a Loader to pick the appropriate sub-editor (chip vs combobox) in the same synchronous call — no visible flicker.
Forwards editorValueChanged and rememberValueBoxClicked from the active sub-editor to MMFormPage via Connections.
• CMakeLists.txt: registers the new MMFormChipEditor.qml QML source.

Before (check the road condition):
screenshot_before_dropdown

After:
screenshot_after_chips

saberraz and others added 2 commits March 16, 2026 14:12
Value-map fields with 4 or fewer options now render all choices as
inline pill/chip buttons directly on the form, eliminating the need to
open a drawer for short lists (e.g. a 4-value condition rating).

Fields with 5 or more options continue to use the existing dropdown
drawer (MMFormComboboxBaseEditor + MMListMultiselectDrawer) unchanged,
so there is no regression for longer lists.

Implementation
--------------
• New MMFormChipEditor.qml (extends MMBaseInput):
  - Displays options as a horizontally-wrapping Flow of pill Rectangles.
  - Selected chip: grassColor (#73D19C) background.
  - Unselected chip: white background with forestColor border.
  - Read-only state: MouseArea disabled, chips still visible.
  - Emits editorValueChanged / rememberValueBoxClicked for MMFormPage
    compatibility.

• Refactored MMFormValueMapEditor.qml (now an Item wrapper):
  - Parses _fieldConfig into a shared ListModel in Component.onCompleted.
  - After parsing, sets _modelReady = true which triggers a Loader to
    pick the appropriate sub-editor (chip vs combobox) in the same
    synchronous call — no visible flicker.
  - Forwards editorValueChanged and rememberValueBoxClicked from the
    active sub-editor to MMFormPage via Connections.

• CMakeLists.txt: registers the new MMFormChipEditor.qml QML source.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…border

With only 2 options the previous design (green fill vs white + dark
border) could be ambiguous about which chip was active.

Changes to MMFormChipEditor:
- Selected chip now shows a leading checkmark icon (forestColor) so
  the active value is unambiguous regardless of how many chips exist.
- Unselected chip border changes from forestColor to greyColor (#E2E2E2)
  so unselected chips visually recede behind the selected one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 65221 dmg Expires: 14/06/2026 #6522
linux Build 📬 Mergin Maps 65331 x86_64 Expires: 14/06/2026 #6533
win64 Build 📬 Mergin Maps 57171 win64 Expires: 14/06/2026 #5717
Android Build 📬 Mergin Maps 783311 APK [armeabi-v7a] Expires: 14/06/2026 #7833
Android Build 📬 Mergin Maps 783351 APK [arm64-v8a] Expires: 14/06/2026 #7833
iOS Build 📬 Build number: 26.03.877311 #8773

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