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

Add an override to useTypeAhead behavior from @floating-ui/react allowing use <input /> in DropDown.Header #1394

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dragonlipz
Copy link

@dragonlipz dragonlipz commented May 13, 2024

This is for issue #1341 preventing the use of <input /> or <TextInput /> controls in the header section of a DropDown.

This Does add a new property to the <DropDown /> component to prevent default behavior of @floating-ui/react's useTypeAhead functionality. That, according to @floating-ui/react documentation, should not be used for typeable elements.

Note
This Hook should not be used for typeable <input /> elements. It is intended to be used on menu buttons for a dropdown menu or select menu, rather than a combobox that is searchable.

New Prop:
DropdownProps.enableTypeAhead?: boolean
default: true
Non-breaking, to existing behavior. When set to false, disables the 'useTypeAhead' functionality.

I'm uncertain if this is the desired naming of the property. disableTypeAhead seems more appropriate, but then it's negative use may be more confusing for users.

Summary by CodeRabbit

  • New Features

    • Introduced a story demonstrating a dropdown with an input header, allowing users to type without triggering type-ahead search.
  • Documentation

    • Added guidance on setting enableTypeAhead to false for <Dropdown> components with complex headers to prevent unintended item search.
    • Updated instructions in the dropdown.mdx file regarding enableTypeAhead setting.

… using input html types in header of DropDown
Copy link

changeset-bot bot commented May 13, 2024

⚠️ No Changeset found

Latest commit: ea7bd48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 0:56am
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 0:56am

Copy link
Contributor

coderabbitai bot commented May 13, 2024

Walkthrough

The changes bring a new capability to the Dropdown component, enabling users to deactivate type-ahead functionality when dealing with intricate headers containing input controls. This update ensures that input field keystrokes are not mistaken for item search commands. Additionally, a fresh story showcases this functionality.

Changes

Files/Paths Change Summary
apps/web/content/docs/components/dropdown.mdx Added guidance to disable enableTypeAhead for complex headers with input controls.
.../Dropdown/Dropdown.stories.tsx Introduced a new story WithUsableInputHeader illustrating a dropdown with an input header.
.../Dropdown/Dropdown.tsx Enhanced DropdownProps with enableTypeAhead and updated DropdownComponent accordingly.

In the realm of code where dropdowns prance,
A new feature grants users a chance.
Type-ahead subdued for inputs so keen,
Keystrokes now glide smooth and serene.
Tales are woven, and docs are clear,
For developers both far and near.
🎩🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (4)
apps/web/content/docs/components/dropdown.mdx (4)

Line range hint 6-6: Use "i.e." instead of "ie.".

- (ie. a button)
+ (i.e. a button)

Line range hint 8-8: Add a comma after "Tailwind CSS".

- Tailwind CSS and you can use
+ Tailwind CSS, and you can use

Line range hint 18-18: Remove "of" for conciseness.

- inside of the main `<Dropdown>` component.
+ inside the main `<Dropdown>` component.

Line range hint 68-68: Add a comma after "trigger element".

- trigger element you can use
+ trigger element, you can use
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2afa3c8 and 9ade36f.
Files selected for processing (3)
  • apps/web/content/docs/components/dropdown.mdx (1 hunks)
  • packages/ui/src/components/Dropdown/Dropdown.stories.tsx (1 hunks)
  • packages/ui/src/components/Dropdown/Dropdown.tsx (3 hunks)
Additional Context Used
LanguageTool (4)
apps/web/content/docs/components/dropdown.mdx (4)

Near line 6: The abbreviation “i.e.” (= that is) requires two periods.
Context: ...ems when clicking on a trigger element (ie. a button) that you can use to build dro...


Near line 8: Possible missing comma found.
Context: ... with the utility classes from Tailwind CSS and you can use the custom props from R...


Near line 18: This phrase is redundant. Consider using “inside”.
Context: ...ding child <Dropdown.Item> components inside of the main <Dropdown> component. <Exam...


Near line 68: It seems that a comma is missing.
Context: ...ustom trigger To customize the trigger element you can use renderTrigger property. ...

Additional comments not posted (5)
apps/web/content/docs/components/dropdown.mdx (1)

32-33: The added line is clear and provides necessary information about the new prop.

packages/ui/src/components/Dropdown/Dropdown.stories.tsx (1)

63-78: The new story WithUsableInputHeader is well-implemented and demonstrates the usage of the enableTypeAhead prop effectively.

packages/ui/src/components/Dropdown/Dropdown.tsx (3)

50-50: The new prop enableTypeAhead is correctly added to the DropdownProps interface.


112-112: The default value for enableTypeAhead is correctly set to true in the DropdownComponent.


169-169: The enableTypeAhead prop is correctly used to enable or disable the useTypeahead functionality.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Out of diff range and nitpick comments (1)
apps/web/content/docs/components/dropdown.mdx (1)

Line range hint 56-56: Add a comma for better readability.

There is a missing comma in the sentence.

- Use the `placement` prop to change the placement of the dropdown by choosing one of the following options: `top`, `right`, `bottom` or `left`. If there is not enough space then the dropdown will be automatically repositioned.
+ Use the `placement` prop to change the placement of the dropdown by choosing one of the following options: `top`, `right`, `bottom`, or `left`. If there is not enough space, then the dropdown will be automatically repositioned.
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9ade36f and ea7bd48.
Files selected for processing (1)
  • apps/web/content/docs/components/dropdown.mdx (4 hunks)
Additional Context Used
LanguageTool (1)
apps/web/content/docs/components/dropdown.mdx (1)

Near line 56: Possible missing comma found.
Context: ...ttomorleft`. If there is not enough space then the dropdown will be automatically...

@@ -3,9 +3,9 @@ title: React Dropdown - Flowbite
description: Use the dropdown component to trigger a list of menu items when clicking on an element such as a button or link based on multiple styles, sizes, and placements with React
---

The dropdown component is a UI component built with React that allows you to show a list of items when clicking on a trigger element (ie. a button) that you can use to build dropdown menus, lists, and more.
The dropdown component is a UI component built with React that allows you to show a list of items when clicking on a trigger element (i.e. a button) that you can use to build dropdown menus, lists, and more.
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the description of the dropdown component.

The current description is clear but can be slightly refined for better readability.

- The dropdown component is a UI component built with React that allows you to show a list of items when clicking on a trigger element (i.e. a button) that you can use to build dropdown menus, lists, and more.
+ The dropdown component is a UI element built with React that displays a list of items when a trigger element (e.g., a button) is clicked. You can use it to build dropdown menus, lists, and more.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
The dropdown component is a UI component built with React that allows you to show a list of items when clicking on a trigger element (i.e. a button) that you can use to build dropdown menus, lists, and more.
The dropdown component is a UI element built with React that displays a list of items when a trigger element (e.g., a button) is clicked. You can use it to build dropdown menus, lists, and more.


The default styles are built with the utility classes from Tailwind CSS and you can use the custom props from React to customize the behaviour and positioning of the dropdowns.
The default styles are built with the utility classes from Tailwind CSS, and you can use the custom props from React to customize the behaviour and positioning of the dropdowns.
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the description of the default styles and customization options.

The current description is clear but can be slightly refined for better readability.

- The default styles are built with the utility classes from Tailwind CSS, and you can use the custom props from React to customize the behaviour and positioning of the dropdowns.
+ The default styles are built using utility classes from Tailwind CSS. You can customize the behavior and positioning of the dropdowns using custom props from React.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
The default styles are built with the utility classes from Tailwind CSS, and you can use the custom props from React to customize the behaviour and positioning of the dropdowns.
The default styles are built using utility classes from Tailwind CSS. You can customize the behavior and positioning of the dropdowns using custom props from React.

Comment on lines +32 to +33
For more complex headers that include an `<input>` or `<TextInput>` control, it's necessary to set `enableTypeAhead` to false on the `<Dropdown>` to prevent item search interpretation of keystrokes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure clarity in the new instruction for complex headers.

The added instruction is clear but can be slightly refined for better readability.

- For more complex headers that include an `<input>` or `<TextInput>` control, it's necessary to set `enableTypeAhead` to false on the `<Dropdown>` to prevent item search interpretation of keystrokes.
+ For more complex headers that include an `<input>` or `<TextInput>` control, set `enableTypeAhead` to `false` on the `<Dropdown>` to prevent keystrokes from being interpreted as item searches.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
For more complex headers that include an `<input>` or `<TextInput>` control, it's necessary to set `enableTypeAhead` to false on the `<Dropdown>` to prevent item search interpretation of keystrokes.
For more complex headers that include an `<input>` or `<TextInput>` control, set `enableTypeAhead` to `false` on the `<Dropdown>` to prevent keystrokes from being interpreted as item searches.

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.

None yet

1 participant