Repository navigation
feat: update version to 2.1.0 and add action prop to AsyncSearchableS… - #133
Conversation
📝 WalkthroughWalkthroughThis PR bumps the package version to 2.1.0 and introduces a new optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/AsyncSearchableSelect.tsx (1)
1-24: Prefer a type-only React import forReactNode.
This avoids a value import that’s only needed for types.♻️ Suggested change
-import React from 'react'; +import type { ReactNode } from 'react'; @@ - action?: React.ReactNode; + action?: ReactNode;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/AsyncSearchableSelect.tsx` around lines 1 - 24, The code imports the entire React namespace but only uses the ReactNode type for the 'action' prop in AsyncSearchableSelectProps; switch to a type-only import: replace the top-level "import React from 'react';" with "import type { ReactNode } from 'react';" and update the prop type declaration from "action?: React.ReactNode" to "action?: ReactNode" (adjust any other React.* type uses similarly) so the runtime doesn't import an unused React value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/stories/AsyncSearchableSelect.stories.tsx`:
- Around line 112-126: In the WithAction story object replace the invalid prop
key MenuPortal with the correct react-select prop menuPosition set to 'fixed'
(remove MenuPortal entry and add menuPosition: 'fixed' inside the args for the
WithAction Story) while keeping menuPortalTarget as-is; update the args in the
WithAction Story definition to use menuPosition so the select uses fixed
positioning.
---
Nitpick comments:
In `@src/components/AsyncSearchableSelect.tsx`:
- Around line 1-24: The code imports the entire React namespace but only uses
the ReactNode type for the 'action' prop in AsyncSearchableSelectProps; switch
to a type-only import: replace the top-level "import React from 'react';" with
"import type { ReactNode } from 'react';" and update the prop type declaration
from "action?: React.ReactNode" to "action?: ReactNode" (adjust any other
React.* type uses similarly) so the runtime doesn't import an unused React
value.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.jsonsrc/components/AsyncSearchableSelect.tsxsrc/stories/AsyncSearchableSelect.stories.tsx
| export const WithAction: Story = { | ||
| args: { | ||
| className: 8000 '', | ||
| defaultOptions: [ | ||
| { label: 'Bangladesh', value: 'BD' }, | ||
| { label: 'India', value: 'IN' }, | ||
| { label: 'Pakistan', value: 'PK' }, | ||
| { label: 'Sri Lanka', value: 'SL' }, | ||
| ], | ||
| label: 'Countries', | ||
| helpText: 'This is a help text example', | ||
| errors: [], | ||
| required: true, | ||
| menuPortalTarget: document.body, | ||
| MenuPortal: 'fixed', |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, find and examine the AsyncSearchableSelect.stories.tsx file
find . -type f -name "AsyncSearchableSelect.stories.tsx" | head -5Repository: getdokan/dokan-ui
Length of output: 108
🏁 Script executed:
# Also search for the AsyncSearchableSelect component definition
find . -type f \( -name "*.ts" -o -name "*.tsx" \) | xargs grep -l "AsyncSearchableSelect" | grep -v ".stories" | head -10Repository: getdokan/dokan-ui
Length of output: 119
🌐 Web query:
react-select 5.x props MenuPortal menuPosition menuPortalTarget documentation
💡 Result:
In react-select 5.x, the relevant props are:
menuPortalTarget?: HTMLElement— enables portaling and sets the DOM node the menu portal mounts into (e.g.document.body). The menu uses the built-inMenuPortalcomponent when this prop is provided. [1][3]menuPosition?: "absolute" | "fixed"(default"absolute") — sets the CSSpositionused for the menu;"fixed"is commonly used with portals/modals to avoid clipping/scroll-container issues. [1]- Styling the portal wrapper: use the
stylesprop keymenuPortal(e.g. to setzIndex). [2]
Example:
import Select from "react-select";
<Select
menuPortalTarget={document.body}
menuPosition="fixed"
styles={{
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
}}
/>;Sources: React Select Props API (menuPortalTarget, menuPosition) [1], Styles API (menuPortal style key) [2], Components docs (MenuPortal is replaceable/customizable) [3].
[1] https://react-select-oss.netlify.app/props
[2] https://react-select-oss.netlify.app/styles
[3] https://react-select-oss.netlify.app/components
🏁 Script executed:
cat -n ./src/stories/AsyncSearchableSelect.stories.tsx | sed -n '100,130p'Repository: getdokan/dokan-ui
Length of output: 907
🏁 Script executed:
cat ./src/components/AsyncSearchableSelect.tsxRepository: getdokan/dokan-ui
Length of output: 5279
Replace MenuPortal with menuPosition: 'fixed'.
MenuPortal is not a valid prop for react-select; the correct prop for fixed positioning is menuPosition.
✅ Suggested fix
- MenuPortal: 'fixed',
+ menuPosition: 'fixed',📝 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. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export const WithAction: Story = { | |
| args: { | |
| className: '', | |
| defaultOptions: [ | |
| { label: 'Bangladesh', value: 'BD' }, | |
| { label: 'India', value: 'IN' }, | |
| { label: 'Pakistan', value: 'PK' }, | |
| { label: 'Sri Lanka', value: 'SL' }, | |
| ], | |
| label: 'Countries', | |
| helpText: 'This is a help text example', | |
| errors: [], | |
| required: true, | |
| menuPortalTarget: document.body, | |
| MenuPortal: 'fixed', | |
| export const WithAction: Story = { | |
| args: { | |
| className: '', | |
| defaultOptions: [ | |
| { label: 'Bangladesh', value: 'BD' }, | |
| { label: 'India', value: 'IN' }, | |
| { label: 'Pakistan', value: 'PK' }, | |
| { label: 'Sri Lanka', value: 'SL' }, | |
| ], | |
| label: 'Countries', | |
| helpText: 'This is a help text example', | |
| errors: [], | |
| required: true, | |
| menuPortalTarget: document.body, | |
| menuPosition: 'fixed', |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/stories/AsyncSearchableSelect.stories.tsx` around lines 112 - 126, In the
WithAction story object replace the invalid prop key MenuPortal with the correct
react-select prop menuPosition set to 'fixed' (remove MenuPortal entry and add
menuPosition: 'fixed' inside the args for the WithAction Story) while keeping
menuPortalTarget as-is; update the args in the WithAction Story definition to
use menuPosition so the select uses fixed positioning.
There was a problem hiding this comment.
Pull request overview
This pull request adds an optional action prop to the AsyncSearchableSelect component, allowing developers to place interactive controls (like "+ Add New" buttons) next to the label. The version is appropriately bumped from 2.0.6 to 2.1.0, following semantic versioning for a backward-compatible feature addition.
Changes:
- Added optional
actionprop to AsyncSearchableSelect component for rendering action elements adjacent to the label - Refactored label layout from inline-block to flex layout to accommodate the action element
- Added new
WithActionstory demonstrating the feature usage - Version bump to 2.1.0
Re 8000 viewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Version bumped to 2.1.0 for the new feature |
| src/components/AsyncSearchableSelect.tsx | Added action prop type definition, refactored label layout to flex container with justify-between to position action alongside label |
| src/stories/AsyncSearchableSelect.stories.tsx | Added WithAction story demonstrating usage of the new action prop with a button example |
| @@ -1,3 +1,4 @@ | |||
| import React from 'react'; | |||
There was a problem hiding this comment.
The React import is unnecessary in this file. With the new JSX transform configured in tsconfig.json ("jsx": "react-jsx"), React doesn't need to be imported for JSX to work. Since this component only uses the React.ReactNode type annotation and doesn't use any React APIs (hooks, React.FC, etc.), the import can be safely removed. TypeScript will still recognize React.ReactNode from the global React types.
This follows the same pattern used in SearchableSelect.tsx and TaggableSelect.tsx, which also use React.ReactNode without importing React.
| import React from 'react'; |
| {props.label} | ||
| {props.required && <span className={'ms-0.5 text-danger-500'}>*</span>} | ||
| </label> | ||
| {props.action && <div>{props.action}</div>} |
There was a problem hiding this comment.
The wrapper div around props.action is unnecessary. The action prop is already a ReactNode and can be rendered directly without an extra wrapper. This simplifies the markup and follows React best practices.
Change from:
{props.action &&
To:
{props.action && props.action}
Or even more concisely:
{props.action}
| {props.action && <div>{props.action}</div>} | |
| {props.action} |
…elect component
Summary by CodeRabbit
New Features
Chores