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(InputMenu/SelectMenu): add create-item prop #2472

Merged
merged 31 commits into from
Nov 12, 2024
Merged

Conversation

ineshbose
Copy link
Member

@ineshbose ineshbose commented Oct 27, 2024

πŸ”— Linked issue

Resolves #2434

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Re-adds creatable to SelectMenu (maybe this should also exist in InputMenu too).

Let me know if this was intentionally left out (@benjamincanac)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

/cc @sandros94

@benjamincanac
Copy link
Member

I first left it out because I thought to let the users define it using the items prop for more flexibility but now that I think of it the filtered results are not exposed.

@benjamincanac benjamincanac added the v3 #1289 label Oct 28, 2024
Copy link

pkg-pr-new bot commented Oct 30, 2024

pnpm add https://pkg.pr.new/@nuxt/ui@2472

commit: 38b962c

@ineshbose ineshbose marked this pull request as ready for review October 30, 2024 18:22
@ineshbose ineshbose changed the title chore(SelectMenu): reimplement creatable chore(SelectMenu/InputMenu): reimplement creatable Oct 30, 2024
@ineshbose ineshbose changed the title chore(SelectMenu/InputMenu): reimplement creatable feat(SelectMenu/InputMenu): allow create-item prop Nov 5, 2024
@benjamincanac benjamincanac changed the title feat(SelectMenu/InputMenu): allow create-item prop feat(InputMenu/SelectMenu): allow create-item prop Nov 5, 2024
@benjamincanac
Copy link
Member

I just tried the docs examples for both InputMenu and SelectMenu, when clicking the Add ... I get this warning:

[Vue warn]: Invalid prop: type check failed for prop "modelValue". Expected String | Number, got Boolean with value true. 

@ineshbose
Copy link
Member Author

I just tried the docs examples for both InputMenu and SelectMenu, when clicking the Add ... I get this warning:

[Vue warn]: Invalid prop: type check failed for prop "modelValue". Expected String | Number, got Boolean with value true. 

Thanks for pointing out - sorry I wasn't 100% sure of how to use the component-code prose for the docs. It should be fine now!

@benjamincanac
Copy link
Member

What is the intent behind the create event? To add to the initial array?

There is an error inside, it's typed with the value but receives the event (from the @select on the ComboboxItem). Maybe we should have the event and the value?

@ineshbose
Copy link
Member Author

What is the intent behind the create event? To add to the initial array?

Yes, I think its an explicit event for any developer to know when the create has happened.

There is an error inside, it's typed with the value but receives the event (from the @select on the ComboboxItem). Maybe we should have the event and the value?

Hmm, I suppose the better type for it is V extends string ? Record<V | '[label] (should be keyof T)', string> : string

Copy link
Member

benjamincanac commented Nov 6, 2024

No I meant, the first parameter you receive when using @create is an Event not the item value.
CleanShot 2024-11-06 at 17.36.15@2x.png

@ineshbose
Copy link
Member Author

No I meant, the first parameter you receive when using @create is an Event not the item value. CleanShot 2024-11-06 at 17.36.15@2x.png

Oh! My bad. I think that will also contain the target value as string too!

@benjamincanac
Copy link
Member

@ineshbose For the docs, don't you think it would be better in the examples section? We could demonstrate a real example with @create event.

@ineshbose
Copy link
Member Author

@ineshbose For the docs, don't you think it would be better in the examples section? We could demonstrate a real example with @create event.

Does that replace the currently added section or in addition to that? Quite indecisive when writing docs myself, so if you've got ideas - fire away! πŸ˜„

Copy link
Member

Sure, I'll take care of it 😊

@benjamincanac
Copy link
Member

Before I start the docs, how are we supposed to get the created item from the @create event? πŸ€”

@ineshbose
Copy link
Member Author

Before I start the docs, how are we supposed to get the created item from the @create event? πŸ€”

it would be similar to onSelect! Value should be e.target.value

@benjamincanac benjamincanac changed the title feat(InputMenu/SelectMenu): allow create-item prop feat(InputMenu/SelectMenu): add create-item prop Nov 12, 2024
Copy link
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

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

@ineshbose FYI I've updated the docs a bit and handled the locale for "Create".

@benjamincanac
Copy link
Member

I also just added the item as second argument of the create event. It's different than @select since it's binded on item.onSelect (you don't need to know which item it is).

@benjamincanac benjamincanac merged commit f516d7b into nuxt:v3 Nov 12, 2024
@benjamincanac
Copy link
Member

Thanks @ineshbose!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants