Skip to content

Conversation

Artur-
Copy link
Member

@Artur- Artur- commented Aug 25, 2025

Adds a new itemLabelGenerator function property to vaadin-select that allows customizing how item labels are generated from item objects. This enables users to display custom text for items without modifying the underlying data structure.

  • Add itemLabelGenerator property to SelectBaseMixin
  • Update item rendering to use generator function when provided
  • Add TypeScript definitions for ItemLabelGenerator type
  • Add comprehensive tests for the new functionality
  • Include demo showing various use cases

Fixes #8333

🤖 Generated with Claude Code

@web-padawan
Copy link
Member

The issue linked describes combo-box and the PR is for select, should there be another issue?

@Artur-
Copy link
Member Author

Artur- commented Aug 25, 2025

Wouldn't the feature make sense for select, combo-box and also multi-select-combo-box?

@web-padawan
Copy link
Member

There are many merge conflicts, looks like the change was created from an early version where lit versions are still present

@Artur-
Copy link
Member Author

Artur- commented Aug 25, 2025

Yes, I will rebase on latest main

@Artur- Artur- force-pushed the item-label-generator branch 2 times, most recently from 7b1e301 to 64377b6 Compare August 25, 2025 14:51
@Artur-
Copy link
Member Author

Artur- commented Aug 25, 2025

Was easier to code from scratch again..

Artur- and others added 3 commits August 26, 2025 09:37
…select-combo-box

Implement itemLabelGenerator function property that allows custom label generation for items.
The generator function receives an item and returns a string label, taking precedence over
itemLabelPath when both are defined.

- Add itemLabelGenerator to vaadin-select for custom dropdown item labels
- Add itemLabelGenerator to vaadin-combo-box with support for filtering by generated labels
- Multi-select-combo-box inherits itemLabelGenerator for both dropdown and chip labels
- Add comprehensive tests for all three components
- Update dev examples to demonstrate the new feature

Fixes #8333

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add itemLabelGenerator type definition to SelectBaseMixinClass
- Add itemLabelGenerator type definition to ComboBoxItemsMixinClass
- MultiSelectComboBoxMixinClass inherits the type automatically via ComboBoxItemsMixinClass

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Follow the existing pattern of counting overflow chip in total chip count
- Use getChips() helper function consistently with existing tests
- Access chip labels at correct indices (skip overflow chip at [0])
- Set proper width and await nextRender for consistent chip rendering

All tests now pass:
- select: 6/6 tests ✅
- combo-box: 8/8 tests ✅
- multi-select-combo-box: 9/9 tests ✅

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@Artur- Artur- force-pushed the item-label-generator branch from d0e011f to b1b9607 Compare August 26, 2025 06:38
Copy link

@Artur- Artur- changed the title feat(select): add itemLabelGenerator property feat: add itemLabelGenerator property Aug 26, 2025
@Artur- Artur- changed the title feat: add itemLabelGenerator property feat: add itemLabelGenerator property to select, combo box and multi select combo box Aug 26, 2025
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.

Item Label Generator for Combo Box
2 participants