Skip to content

Conversation

@saiponnada
Copy link
Contributor

Description

Fixed logic not to trigger change on focus.

Checklist

  • I verify all changes are within scope of the linked issue
  • I added/updated/removed testing (Storybook in Skin) coverage as appropriate
  • I tested the UI in all supported browsers
  • I did a visual regression check of the components impacted by doing a Percy build and approved the build
  • I tested the UI in dark mode and RTL mode

Copilot AI review requested due to automatic review settings December 10, 2025 18:30
@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: 1cff4e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ebay/ebayui-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@saiponnada saiponnada requested review from LuLaValva and agliga and removed request for agliga and Copilot December 10, 2025 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the star rating select component where the change event was incorrectly being triggered on focus. The fix separates the click and focus handlers so that only click events update the component state and emit change events, while focus events no longer modify state or trigger changes.

Key Changes:

  • Separated click handling logic from the generic event emission logic
  • Added tests to verify focus does not select stars or emit change events

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/ebayui-core/src/components/ebay-star-rating-select/component.ts Added dedicated handleClick method to handle state updates and change events separately from other events
packages/ebayui-core/src/components/ebay-star-rating-select/index.marko Updated onClick handler to use new handleClick method instead of generic emitEvent
packages/ebayui-core/src/components/ebay-star-rating-select/test/test.browser.js Added tests to verify focus doesn't select stars or emit change events
.changeset/free-boats-arrive.md Added changeset documenting the bug fix

Comment on lines 55 to 57
this.emit(name, {
originalEvent,
value: value,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The line this.state.value = value; was removed from emitEvent, but the method still updates state in the new handleClick method. This creates a potential issue where focus events can still emit with a value, even though they shouldn't modify state. Consider adding a guard in emitEvent or making it clearer that this method should only be used for non-state-changing events.

Suggested change
this.emit(name, {
originalEvent,
value: value,
// Only emit the passed value for "change" events; otherwise, emit the current state value
this.emit(name, {
originalEvent,
value: name === "change" ? value : this.state.value,

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@saiponnada saiponnada Dec 12, 2025

Choose a reason for hiding this comment

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

Contemplated about this approach first, preferred to keep seperation instead.


it("then it does not emit change event", () => {
const changeEvents = component.emitted("change");
expect(changeEvents).has.length(0);
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The test verifies that changeEvents has length 0, but it should also verify that changeEvents is either undefined or null if no events were emitted, as this would be the expected behavior when component.emitted() is called for an event that was never triggered.

Copilot uses AI. Check for mistakes.
@saiponnada saiponnada merged commit 025ce05 into main Dec 12, 2025
3 checks passed
@saiponnada saiponnada deleted the star-rating branch December 12, 2025 19:36
@github-actions github-actions bot mentioned this pull request Dec 12, 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.

ebay-star-rating-select: first star is automatically selected

3 participants