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

[Select] Create options onPaste event #162

Merged
merged 3 commits into from
Apr 30, 2024
Merged

[Select] Create options onPaste event #162

merged 3 commits into from
Apr 30, 2024

Conversation

SerhiiTsybulskyi
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Screen.Recording.2024-04-30.at.11.38.46.mov

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@SerhiiTsybulskyi SerhiiTsybulskyi requested a review from amcdnl April 30, 2024 08:41
@SerhiiTsybulskyi SerhiiTsybulskyi self-assigned this Apr 30, 2024
Copy link

netlify bot commented Apr 30, 2024

Deploy Preview for reablocks-storybook ready!

Name Link
🔨 Latest commit 45b1166
🔍 Latest deploy log https://app.netlify.com/sites/reablocks-storybook/deploys/6630dd8c18fc450008b62205
😎 Deploy Preview https://deploy-preview-162--reablocks-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -0,0 +1,102 @@
export const keyNameToCode = {
Copy link
Contributor Author

@SerhiiTsybulskyi SerhiiTsybulskyi Apr 30, 2024

Choose a reason for hiding this comment

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

I've added this mapping to keep readability for

selectOnKeys={['Space', 'Comma']

I think this more friendly format instead array of numbers (key codes)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is works for Keyboard events (manually filling) but didn't work on paste due to ClipboardEvent (another way to interact with input needs a little bit different handler)

src/form/Select/Select.tsx Outdated Show resolved Hide resolved
@@ -639,7 +645,7 @@ export const Select: FC<Partial<SelectProps>> = ({

const onPasteHandler = useCallback(
(e: React.ClipboardEvent<HTMLInputElement>) => {
if (createable && multiple) {
if (createOnPaste && multiple) {
Copy link
Member

Choose a reason for hiding this comment

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

Does it select if its already a 'created' option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

if creatable = false but I paste in a option this condition is invalid. I think it should be selectOnPaste then when combined w/ creatable would create them or of not just select them.

@amcdnl amcdnl merged commit e4c8e9a into master Apr 30, 2024
5 checks passed
@amcdnl amcdnl deleted the select-onpaste branch April 30, 2024 12:20
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