Skip to content

fix: use closest() in Picker to handle clicks on child elements#44

Merged
akaash2512 merged 1 commit into
swisscom:mainfrom
atulmahind:bugfix/item-selection-in-picker
May 6, 2026
Merged

fix: use closest() in Picker to handle clicks on child elements#44
akaash2512 merged 1 commit into
swisscom:mainfrom
atulmahind:bugfix/item-selection-in-picker

Conversation

@atulmahind

@atulmahind atulmahind commented May 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #43 - a TypeError on the script-builder page when clicking items in the Picker component that contain child elements (e.g. coral-icon).

Problem

The selectlistChanged click handler in Picker.tsx cast e.target directly to the list item element. When a child element inside a coral-selectlist-item (such as a coral-icon) is clicked, e.target resolves to the child rather than the list item itself. This causes item.value to be undefined, leading to the following error in the browser console:

Uncaught TypeError: Cannot read properties of undefined (reading 'config')

Solution

Use .closest('coral-selectlist-item') to traverse up from the actual click target to the nearest list item, regardless of which child element was clicked. If no list item is found (e.g. a click on the container itself), the handler returns early.

Changes

src/main/frontend/widgets/Picker.tsx - updated selectlistChanged to use closest() instead of a direct cast of e.target

Testing

@atulmahind

Copy link
Copy Markdown
Contributor Author

Oh, tests failed locally (macOS) because chromium-darwin snapshots don't exist in the repo, only chromium-linux ones do, which is why CI passed.

The fix itself is unaffected by this.

@akaash2512 akaash2512 merged commit 1ebe1cb into swisscom:main May 6, 2026
2 checks passed
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.

Picker component fails when clicking on child elements (e.g. icons) inside coral-selectlist-item

2 participants