Skip to content

feat(select): enable showing a custom component along with options#4068

Merged
Kiarokh merged 4 commits intomainfrom
select-option-component
May 8, 2026
Merged

feat(select): enable showing a custom component along with options#4068
Kiarokh merged 4 commits intomainfrom
select-option-component

Conversation

@LucyChyzhova
Copy link
Copy Markdown
Contributor

@LucyChyzhova LucyChyzhova commented May 8, 2026

Summary by CodeRabbit

  • New Features

    • Select now supports rendering a small custom component alongside options and in the selected value.
    • Added an example showcasing the select with a primary/custom component.
  • Bug Fixes

    • Mobile/native-select behavior adjusted so options with custom components use the custom UI, others use native select.
  • Tests

    • End-to-end tests added to cover primary-component rendering and mobile behavior.

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

@LucyChyzhova LucyChyzhova requested a review from a team as a code owner May 8, 2026 11:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@Kiarokh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 53 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 10d6250a-4810-4d4b-8343-3bf27efc4169

📥 Commits

Reviewing files that changed from the base of the PR and between 3a31537 and 3d387ce.

⛔ Files ignored due to path filters (1)
  • etc/lime-elements.api.md is excluded by !etc/lime-elements.api.md
📒 Files selected for processing (8)
  • src/components/list-item/list-item.tsx
  • src/components/select/examples/select-with-primary-component.tsx
  • src/components/select/option.types.ts
  • src/components/select/select.e2e.tsx
  • src/components/select/select.scss
  • src/components/select/select.template.tsx
  • src/components/select/select.tsx
  • src/util/render-list-component.tsx
📝 Walkthrough

Walkthrough

Adds optional primaryComponent to select options with a shared renderer, integrates rendering into list items and select template (including selected trigger), updates mobile-native decision to avoid native <select> when primary components exist, adds styles, example, and e2e tests.

Changes

Primary Component Feature for limel-select

Layer / File(s) Summary
Type Contract
src/components/select/option.types.ts
Option interface gains optional primaryComponent?: ListComponent and imports ListComponent.
Render Utility
src/util/render-list-component.tsx
New renderListComponent(component) that validates component.name and returns a JSX custom-element tag with component.props or undefined.
Template Rendering
src/components/select/select.template.tsx
createMenuItems stores primaryComponent in ListItems; renderOptionWithIcon and selected-trigger rendering include the rendered primary component; helpers getSelectedPrimaryComponent and renderPrimaryComponent added.
ListItem Wiring
src/components/list-item/list-item.tsx
List item rendering replaced inline primary-component instantiation with a call to renderListComponent(this.primaryComponent).
Native Select Guard
src/components/select/select.tsx
Adds memoized hasPrimaryComponentMemo, @Watch('options'), and shouldRenderNative() so native <select> on mobile is used only when no non-separator option has a primaryComponent.name and multiple is false.
Styling
src/components/select/select.scss
New .limel-select__selected-option__primary-component rule: inline-flex, align-items: center, margin-right: 0.25rem, flex-shrink: 0.
Example
src/components/select/examples/select-with-primary-component.tsx
New SelectExample demonstrating options with primaryComponent rendering limel-circular-progress, wired to component state and change handler.
Tests
src/components/select/select.e2e.tsx
E2E tests asserting primary component appears in trigger and that options with primary components prevent using native <select> on mobile.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • adrianschmidt
  • jgroth
  • Kiarokh
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(select): enable showing a custom component along with options' directly and clearly describes the main feature addition, matching the changeset's primary purpose of enabling custom component rendering in select options.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch select-option-component

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kiarokh Kiarokh self-assigned this May 8, 2026
@Kiarokh Kiarokh marked this pull request as draft May 8, 2026 11:51
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4068/

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/select/select.tsx (1)

385-409: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

getFirstNativeAutoSelectOption fires spuriously on mobile when primaryComponent is present

The new hasPrimaryComponent() guard correctly prevents native <select> rendering, but getFirstNativeAutoSelectOption is only gated on !this.isMobileDevice and this.multiple. On a mobile device whose options include a primaryComponent, native is false (custom dropdown shown), yet getFirstNativeAutoSelectOption still returns the first option, causing openMenu to emit an unwanted change event before the user makes any selection.

🐛 Proposed fix
 private getFirstNativeAutoSelectOption(): Option | undefined {
-    if (this.hasChanged || !this.isMobileDevice || this.multiple) {
+    if (this.hasChanged || !this.isMobileDevice || this.multiple || this.hasPrimaryComponent()) {
         return undefined;
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/select/select.tsx` around lines 385 - 409,
getFirstNativeAutoSelectOption currently runs on mobile even when a
primaryComponent is present, causing an unwanted auto-selection; update
getFirstNativeAutoSelectOption to also return undefined if hasPrimaryComponent()
is true (in addition to the existing guards this.isMobileDevice and
this.multiple) so it won’t pick the first option when the component is rendering
a custom dropdown; check the start of getFirstNativeAutoSelectOption (the
early-return conditions) and add the hasPrimaryComponent() guard before
computing options.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/select/select.tsx`:
- Around line 385-409: getFirstNativeAutoSelectOption currently runs on mobile
even when a primaryComponent is present, causing an unwanted auto-selection;
update getFirstNativeAutoSelectOption to also return undefined if
hasPrimaryComponent() is true (in addition to the existing guards
this.isMobileDevice and this.multiple) so it won’t pick the first option when
the component is rendering a custom dropdown; check the start of
getFirstNativeAutoSelectOption (the early-return conditions) and add the
hasPrimaryComponent() guard before computing options.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cb4885b8-3e8a-4023-9a41-48c8e120dfd3

📥 Commits

Reviewing files that changed from the base of the PR and between c3e14c2 and 4c741de.

⛔ Files ignored due to path filters (1)
  • etc/lime-elements.api.md is excluded by !etc/lime-elements.api.md
📒 Files selected for processing (5)
  • src/components/select/examples/select-with-primary-component.tsx
  • src/components/select/option.types.ts
  • src/components/select/select.scss
  • src/components/select/select.template.tsx
  • src/components/select/select.tsx

@Kiarokh Kiarokh force-pushed the select-option-component branch from 4c741de to 3a31537 Compare May 8, 2026 12:42
@Kiarokh Kiarokh marked this pull request as ready for review May 8, 2026 12:45
@Kiarokh Kiarokh force-pushed the select-option-component branch from 3a31537 to 2ef910e Compare May 8, 2026 12:48
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/select/examples/select-with-primary-component.tsx`:
- Line 29: Mark the instance properties as readonly: change the declaration of
the options property to "private readonly options: Option[] = [...]" and the
class property handleChange (the arrow function assigned to handleChange) to
"private readonly handleChange = (...) => { ... }" so neither can be reassigned;
update both occurrences (around the options definition and the handleChange
property) to suppress SonarCloud warnings and communicate intent.

In `@src/util/render-list-component.tsx`:
- Around line 4-15: The JSDoc for renderListComponent is missing a `@param` for
the component parameter; update the block above the renderListComponent function
to include a `@param` component {ListComponent | undefined} with a short
description (e.g., "the ListComponent to render, or undefined") so the
jsdoc/require-param lint rule passes while keeping the existing description of
return behavior intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ddc2e013-bd11-44a9-a23b-fd093c1aef05

📥 Commits

Reviewing files that changed from the base of the PR and between 4c741de and 3a31537.

⛔ Files ignored due to path filters (1)
  • etc/lime-elements.api.md is excluded by !etc/lime-elements.api.md
📒 Files selected for processing (8)
  • src/components/list-item/list-item.tsx
  • src/components/select/examples/select-with-primary-component.tsx
  • src/components/select/option.types.ts
  • src/components/select/select.e2e.tsx
  • src/components/select/select.scss
  • src/components/select/select.template.tsx
  • src/components/select/select.tsx
  • src/util/render-list-component.tsx

Comment thread src/components/select/examples/select-with-primary-component.tsx Outdated
Comment thread src/util/render-list-component.tsx
@Kiarokh Kiarokh force-pushed the select-option-component branch 2 times, most recently from 5cae4a6 to e334ce4 Compare May 8, 2026 13:06
Kiarokh added 3 commits May 8, 2026 15:10
The `primaryComponent` slot rendered any string passed in `name` as a
JSX tag. With consumer-supplied props spread on the result, a malicious
or untrusted `name` like `iframe`, `script`, or `a` could be rendered
with arbitrary attributes.

Reject names that don't contain a hyphen, matching the HTML custom
element spec. Custom elements always contain a hyphen, so legitimate
consumers are unaffected.
Move the `ListComponent` rendering logic, including the hyphen check
introduced in the previous commit, out of `list-item.tsx` and into
`src/util/render-list-component.tsx`. This allows other components
that render the same data shape (such as `limel-select`) to share the
exact same rendering and validation behavior, so future changes to how
`ListComponent` is interpreted only need to land in one place.

No behavior change.
Adds a `primaryComponent` field to `Option` so consumers can render a
custom component along with the icon and text of an option. The component
is rendered both in the dropdown list (forwarded to `limel-list-item`)
and in the trigger area when the option is selected.

When any option carries a `primaryComponent`, the native mobile dropdown
is bypassed in favor of the menu-based dropdown, since native `<option>`
elements cannot host custom components.

Both render paths go through the shared `renderListComponent` helper, so
the hyphen-based safety check on the component name applies here too.
@Kiarokh Kiarokh force-pushed the select-option-component branch from e334ce4 to d185bc6 Compare May 8, 2026 13:11
@Kiarokh Kiarokh enabled auto-merge (rebase) May 8, 2026 13:15
@Kiarokh Kiarokh merged commit 7e0b5b2 into main May 8, 2026
10 checks passed
@Kiarokh Kiarokh deleted the select-option-component branch May 8, 2026 13:18
@lime-opensource
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 39.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants