Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SelectItem): Emit a select event when an option is selected #1513

Open
wants to merge 5 commits into
base: v2
Choose a base branch
from

Conversation

kilobyte2007
Copy link
Contributor

@kilobyte2007 kilobyte2007 commented Dec 19, 2024

I've implemented a select event/emit on the SelectItem so it's consistent with Listbox/Combobox.
This is especially important when using multiple because we cannot rely on update:modelValue as we only need the specific item that was last selected.

Let me know if you have any questions or objections!

Copy link

pkg-pr-new bot commented Dec 19, 2024

Open in Stackblitz

npm i https://pkg.pr.new/reka-ui@1513

commit: 2922b10

@kilobyte2007
Copy link
Contributor Author

I see there's a failing check. But it doesn't seem to be caused by my changes as I didn't touch that part of the code.

@zernonia
Copy link
Member

Yoo @kilobyte2007 ! I've fixed the test issue, can you please rebase the branch on origin/main or merge from origin/main? 😁

Comment on lines +72 to +73
if (ev.defaultPrevented)
return
Copy link
Member

Choose a reason for hiding this comment

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

I think we shouldn't have this conditional here, it will prevent the select from being emitted.

Copy link
Contributor Author

@kilobyte2007 kilobyte2007 Dec 31, 2024

Choose a reason for hiding this comment

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

It is needed because this logic is handling the initial mousedown event, when the dropdown just shows up. Without this check the dropdown just shows up on mousedown and disappears on mouseup.

So basically the check that we had previously - has moved from handleSelect to handleSelectCustomEvent, as this is the place now where we handle the original event. And the check that we have now in handleSelect is for actually preventing the artificially created event.

Let me know if the explanation is clear enough!

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