Skip to content

feat(rich-multi-select): add placeholderWithItems and clearInputOnSelect options - #18

Merged
zmarquez merged 5 commits into
mainfrom
feat/rich-multi-select-placeholder-with-items
Jun 9, 2026
Merged

zmarquez merged 5 commits into
mainfrom
feat/rich-multi-select-placeholder-with-items

Conversation

@zmarquez

@zmarquez zmarquez commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

  • placeholderWithItems: nuevo setting opcional que muestra un texto diferente en el input cuando hay al menos un ítem seleccionado. Al vaciar la selección vuelve al placeholder original.
  • clearInputOnSelect: nuevo setting booleano (false por defecto) que, cuando está activo, limpia el texto de búsqueda y refresca la lista de opciones al seleccionar un ítem. Especialmente útil combinado con remoteUrl.

Test plan

  • Suite de tests pasa sin errores (npm run test)
  • Verificar en example/index.html que el placeholder del select estático cambia al seleccionar y restaura al limpiar
  • Verificar en el ejemplo de carga remota que el input se vacía tras cada selección y permite buscar de nuevo

🤖 Generated with Claude Code

zmarquez and others added 2 commits June 9, 2026 08:37
When placeholderWithItems is set in data-settings, the input placeholder
switches to that text as soon as one item is selected, and reverts to the
original placeholder when all items are removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When clearInputOnSelect is true, the search input is cleared and the
options list refreshed after each item is selected. Useful with remoteUrl
to allow a fresh search immediately after picking an item.

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

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

Adds two new configuration options to the rich-multi-select component to improve UX when selecting multiple items: a dynamic placeholder when items are selected, and an option to clear the search input after each selection (useful for remote search flows).

Changes:

  • Add placeholderWithItems to show an alternate placeholder when there’s at least one selected item.
  • Add clearInputOnSelect to clear the search text and refresh options after selecting an item.
  • Update docs, examples, and tests to cover the new settings.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/components/RichMultiSelect/RichMultiSelect.test.js Adds unit tests for placeholderWithItems and clearInputOnSelect, plus extra TomSelect mock methods needed by the new behavior.
src/components/RichMultiSelect/RichMultiSelect.js Implements placeholder switching on change and input clearing/refresh on item add based on new settings flags.
README.md Documents the new options and includes a usage snippet for placeholderWithItems.
example/index.html Demonstrates clearInputOnSelect with remote loading and adds a new demo for placeholderWithItems.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/components/RichMultiSelect/RichMultiSelect.test.js
Set the initial placeholder value on control_input before calling onChange
so the assertion verifies the value is actually preserved, not just that
it differs from an arbitrary string.

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

zmarquez commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Fixed in a0237b2: set control_input.placeholder to the expected initial value before calling onChange, so the assertion verifies the value is actually preserved rather than just differing from an arbitrary string. (In reply to the Copilot comment on the sin placeholderWithItems test.)

… internal resets

TomSelect resets control_input.placeholder from settings.placeholder on
focus/dropdown events, overwriting our change. Now both are updated in
onChange so TomSelect's internal resets always read the correct value.

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

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/components/RichMultiSelect/RichMultiSelect.js Outdated
Truthy check rejected empty string as a valid placeholderWithItems value.
Consistent with how placeholder uses ?? (null/undefined only).

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

zmarquez commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Fixed in 65b72b2: changed if (s.placeholderWithItems && ...) to if (s.placeholderWithItems != null && ...) so that an empty string is treated as a valid placeholder value, consistent with how placeholder uses ??.

@zmarquez
zmarquez merged commit 8994585 into main Jun 9, 2026
1 check passed
@zmarquez
zmarquez deleted the feat/rich-multi-select-placeholder-with-items branch June 9, 2026 07:51
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