8000 feat: enable menu visibility in TaggableSelect component by mostafizurhimself · Pull Request #129 · getdokan/dokan-ui · GitHub
[go: up one dir, main page]

Skip to content

feat: enable menu visibility in TaggableSelect component - #129

Merged
mostafizurhimself merged 2 commits into
developfrom
feat/taggable-select
Sep 16, 2025
Merged

mostafizurhimself merged 2 commits into
developfrom
feat/taggable-select

Conversation

@mostafizurhimself
@mostafizurhimself mostafizurhimself commented Sep 16, 2025 •
Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Taggable select no longer forces its dropdown into a global portal; menu placement now follows the default/consumer configuration, improving alignment and overlay/scroll behavior.
  • Style

    • Updated select styling to use the app’s standardized color tokens, refining chip, remove-button, loading/no-options, and theme colors for consistent appearance.
  • Chores

    • No public APIs or component behavior were changed.

@mostafizurhimself mostafizurhimself self-assigned this Sep 16, 2025
@coderabbitai
coderabbitai Bot commented Sep 16, 2025 •
Copy link
Copy Markdown

Walkthrough

Removed the forced portaling in TaggableSelect by commenting out menuPortalTarget={document.body} (menu now renders inline or uses consumer-provided target) and renamed CSS variable tokens from var(--colors-...) to var(--color-...) in both TaggableSelect and AsyncSearchableSelect style overrides and theme mappings. No public API changes.

Changes

Cohort / File(s) Summary
TaggableSelect (portal + tokens)
src/components/TaggableSelect.tsx
Commented out menuPortalTarget={document.body} to stop forcing portaling to document.body; retained menuIsOpen behavior if present. Replaced CSS variable usages var(--colors-...) → var(--color-...) in style overrides and theme color mappings. No API/signature changes.
AsyncSearchableSelect (tokens only)
src/components/AsyncSearchableSelect.tsx
Replaced CSS variable usages var(--colors-...) → var(--color-...) across theme.color mappings and style overrides (multiValue, multiValueLabel, multiValueRemove, loadingMessage, noOptionsMessage). No logic or API/signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant TaggableSelect
  participant CreatableSelect
  participant Menu

  User->>TaggableSelect: Focus / Type
  TaggableSelect->>CreatableSelect: render({ /* menuPortalTarget commented out */ })
  CreatableSelect->>Menu: Mount according to default/consumer target (inline or portal)
  User->>Menu: Click option / create
  Menu-->>CreatableSelect: Selection event
  CreatableSelect-->>TaggableSelect: onChange(value)
  TaggableSelect-->>User: Updated tags displayed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Status: Needs Dev Review

Suggested reviewers

  • arafatkn
  • tanmaymishu

Poem

I hop through CSS, a soft palette swap,
Tokens tidy up as I nibble the top.
Menus stay comfy, no wild portal leap —
I guard the dropdown while others sleep. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: enable menu visibility in TaggableSelect component" clearly and concisely summarizes the primary change — restoring menu visibility in TaggableSelect (which matches the removal of the forced menuPortalTarget in src/components/TaggableSelect.tsx). It is specific, relevant, and readable; the additional color token renames in the PR are secondary style changes and do not make the title misleading.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/taggable-select

Tip

8000 👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/TaggableSelect.tsx (1)

10-24: Export props type and build on public RS_CreatableProps

Guidelines: export TS prop types and use named exports. Also stop composing from internal types.

-type CreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = StateManagerProps<
-  Option,
-  IsMulti,
-  Group
-> &
-  CreatableAdditionalProps<Option, Group> & {
-    label?: string;
-    id?: string;
-    className?: string;
-    errors?: string[];
-    helpText?: string;
-    required?: boolean;
-    disabled?: boolean;
-    placeholder?: string;
-  };
+export type TaggableSelectProps<
+  Option,
+  IsMulti extends boolean,
+  Group extends GroupBase<Option>
+> = RS_CreatableProps<Option, IsMulti, Group> & {
+  label?: string;
+  id?: string;
+  className?: string;
+  errors?: string[];
+  helpText?: string;
+  required?: boolean;
+  disabled?: boolean;
+  placeholder?: string;
+};

And update the component signature accordingly (next comment).

🧹 Nitpick comments (7)
src/components/TaggableSelect.tsx (7)

66-68: Default-open behavior: confirm intent; adjust prop order if you want to force it

Placing menuIsOpen before {...props} makes “always open” the default but still allows callers to override via props.menuIsOpen. If you intend to force-open regardless of caller input, move it after the spread. Also consider not opening when disabled.

Option A — force-open (un‑overridable):

-      <CreatableSelect
-        menuIsOpen
-        {...props}
+      <CreatableSelect
+        {...props}
+        menuIsOpen

Option B — default-open, but closed when disabled:

-        menuIsOpen
+        menuIsOpen={!props.disabled && (props.menuIsOpen ?? true)}

69-71: Portal disabled: check clipping/stacking; align menuPosition and styles

With the portal commented out, the menu may be clipped by overflowed parents and the styles.menuPortal block won’t apply. Either re-enable the portal (and switch to menuPosition="fixed") or remove the now-unused menuPortal style.

Option 1 — re-enable portal:

-        // menuPortalTarget={document.body}
-        menuPosition="absolute"
+        menuPortalTarget={document.body}
+        menuPosition="fixed"

130-133: styles.menuPortal is unused without a portal

This block no longer applies when the portal is disabled; remove to avoid confusion.

-          menuPortal: (base) => ({
-            ...base,
-            zIndex: 9999,
-          }),

2-3: Avoid deep imports from node_modules; use public react-select types

Deep paths are unstable and can break on minor upgrades. Prefer public exports from react-select/creatable.

-import { CreatableAdditionalProps } from 'node_modules/react-select/dist/declarations/src/useCreatable';
-import { StateManagerProps } from 'node_modules/react-select/dist/declarations/src/useStateManager';
+import type { CreatableProps as RS_CreatableProps } from 'react-select/creatable';

Then replace the local props alias to build on the public type and export it (see next diff).


26-28: Align component signature with exported props type

Rename to use the exported TaggableSelectProps type.

-const TaggableSelect = <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
-  props: CreatableProps<Option, IsMulti, Group>
+const TaggableSelect = <
+  Option,
+  IsMulti extends boolean = false,
+  Group extends GroupBase<Option> = GroupBase<Option>
+>(
+  props: TaggableSelectProps<Option, IsMulti, Group>
 )

29-29: Use React useId for SSR‑safe, stable ids

Math.random() can cause hydration mismatches. Prefer useId().

+import { useId } from 'react';
...
-  const id = props.id || Math.random().toString();
+  const autoId = useId();
+  const id = props.id ?? autoId;

168-168: Add a named export per guidelines

Keep default export for backward compatibility and add a named export now; deprecate default later.

 export default TaggableSelect;
+export { TaggableSelect };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e053f89 and e51d523.

📒 Files selected for processing (1)
  • src/components/TaggableSelect.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/{components,utils}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/{components,utils}/**/*.{ts,tsx}: Use TypeScript for all components and utilities
Use named exports for components and utilities

Files:

  • src/components/TaggableSelect.tsx
src/components/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/components/**/*.tsx: Use functional React components and hooks for all components
Use Tailwind CSS utility classes for component styling
Define and export TypeScript prop types/interfaces for each component

Files:

  • src/components/TaggableSelect.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{ts,tsx}: Use @ as an alias for src/ in imports
Use debounceSearch for debounced async search interactions

Files:

  • src/components/TaggableSelect.tsx
src/components/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Place new components at src/components/ComponentName.tsx

Files:

  • src/components/TaggableSelect.tsx

@coderabbitai coderabbitai Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (7)
src/components/AsyncSearchableSelect.tsx (2)

71-85: Color token migration to var(--color-*) looks good.

Minor inconsistency with TaggableSelect: neutral30 maps to gray-300 here but gray-200 there. Consider unifying to avoid subtle UI drift across components.


63-66: Props precedence: {...props} last overrides theme/styles/className.

This differs from TaggableSelect (which spreads props first). Recommend standardizing so defaults aren’t accidentally clobbered. Move the spread earlier.

Apply:

-      <AsyncSelect
-        inputId={id}
+      <AsyncSelect
+        {...props}
+        inputId={id}
         isDisabled={props.disabled}
         className={twMerge('shadow-sm', props.className, props.disabled && 'rounded border', hasError && 'hasErrors')}
         placeholder={<div className="text-sm text-gray-400">{props.placeholder || 'Search...'}</div>}
         theme={(theme) => ({
           ...theme,
           colors: {
             ...theme.colors,
             primary: 'var(--color-primary-500)',
             primary75: 'var(--color-primary-200)',
             primary50: 'var(--color-primary-100)',
             primary25: 'var(--color-primary-50)',
             neutral5: 'var(--color-gray-100)',
             neutral10: 'var(--color-gray-100)',
             neutral20: 'var(--color-gray-200)',
             neutral30: 'var(--color-gray-300)',
             neutral40: 'var(--color-gray-400)',
             neutral50: 'var(--color-gray-500)',
             neutral60: 'var(--color-gray-600)',
             neutral70: 'var(--color-gray-700)',
             neutral80: 'var(--color-gray-800)',
             neutral90: 'var(--color-gray-900)',
           },
         })}
         ...
         menuPortalTarget={props.menuPortalTarget}
         menuPosition={props.menuPosition}
-        {...props}
       />

Also applies to: 152-155

src/components/TaggableSelect.tsx (5)

66-71: Removing forced portaling — good. Allow menuPosition override.

Keep default absolute, but let consumers opt into 'fixed' when needed.

-        // menuPortalTarget={document.body}
-        menuPosition="absolute"
+        // menuPortalTarget={document.body}
+        menuPosition={props.menuPosition ?? 'absolute'}

139-158: Normalize theme neutrals across components.

neutral30 is gray-200 here but gray-300 in AsyncSearchableSelect. Pick one for consistency (suggest gray-300).

           colors: {
             ...theme.colors,
             primary: 'var(--color-primary-500)',
             primary75: 'var(--color-primary-200)',
             primary50: 'var(--color-primary-100)',
             primary25: 'var(--color-primary-50)',
             neutral5: 'var(--color-gray-100)',
             neutral10: 'var(--color-gray-100)',
             neutral20: 'var(--color-gray-200)',
-            neutral30: 'var(--color-gray-200)',
+            neutral30: 'var(--color-gray-300)',
             neutral40: 'var(--color-gray-400)',
             neutral50: 'var(--color-gray-500)',
             neutral60: 'var(--color-gray-600)',
             neutral70: 'var(--color-gray-700)',
             neutral80: 'var(--color-gray-800)',
             neutral90: 'var(--color-gray-900)',
           },

10-24: Export the prop type to align with guidelines.

Guideline: “Define and export TS prop types for each component.”

-type CreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = StateManagerProps<
+export type CreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = StateManagerProps<
   Option,
   IsMulti,
   Group
 > &
   CreatableAdditionalProps<Option, Group> & {
     label?: string;
     id?: string;
     className?: string;
     errors?: string[];
     helpText?: string;
     required?: boolean;
     disabled?: boolean;
     placeholder?: string;
   };

2-3: Avoid deep imports from node_modules for types.

Import public types from react-select to reduce breakage risk on library upgrades. Consider switching in a follow-up; I can help draft it.


1-168: Optional: prefer named exports for components (breaking change).

Repo guideline prefers named exports; consider in a separate PR to avoid API break.

Would you like me to open a follow-up PR that converts default exports to named and updates imports across the repo?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e51d523 and 64a3804.

📒 Files selected for processing (2)
  • src/components/AsyncSearchableSelect.tsx (3 hunks)
  • src/components/TaggableSelect.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/{components,utils}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/{components,utils}/**/*.{ts,tsx}: Use TypeScript for all components and utilities
Use named exports for components and utilities

Files:

  • src/components/AsyncSearchableSelect.tsx
  • src/components/TaggableSelect.tsx
src/components/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/components/**/*.tsx: Use functional React components and hooks for all components
Use Tailwind CSS utility classes for component styling
Define and export TypeScript prop types/interfaces for each component

Files:

  • src/components/AsyncSearchableSelect.tsx
  • src/components/TaggableSelect.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{ts,tsx}: Use @ as an alias for src/ in imports
Use debounceSearch for debounced async search interactions

Files:

  • src/components/AsyncSearchableSelect.tsx
  • src/components/TaggableSelect.tsx
src/components/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Place new components at src/components/ComponentName.tsx

Files:

  • src/components/AsyncSearchableSelect.tsx
  • src/components/TaggableSelect.tsx
🧠 Learnings (2)
📚 Learning: 2025-09-04T09:20:19.197Z
Learnt from: CR
PR: getdokan/dokan-ui#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-04T09:20:19.197Z
Learning: Applies to src/utils/index.ts : Define theme colors in src/utils/index.ts as `themeColors`

Applied to files:

  • src/components/AsyncSearchableSelect.tsx
  • src/components/TaggableSelect.tsx
📚 Learning: 2025-09-04T09:20:19.197Z
Learnt from: CR
PR: getdokan/dokan-ui#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-04T09:20:19.197Z
Learning: Applies to tailwind.config.ts : Extend Tailwind colors using `extendedThemeColorsUsingVariables`

Applied to files:

  • src/components/AsyncSearchableSelect.tsx
🔇 Additional comments (5)
src/components/AsyncSearchableSelect.tsx (2)

121-136: Updated multiValue tokens — LGTM.

The var(--color-primary-*) substitutions are correct and consistent.


137-141: Text color to gray-800 — verify contrast in all themes.

If a dark theme or non-white surfaces exist, confirm readability of loading/no-options messages.

Also applies to: 146-151

src/components/TaggableSelect.tsx (3)

113-128: multiValue token migration — LGTM.


133-138: noOptionsMessage color var — LGTM.


113-138: Verify color variable availability.
Automated verification failed (rg/tailwind.config.* not found). Confirm the CSS variables used in src/components/TaggableSelect.tsx (≈lines 11 8000 3–158) and src/components/AsyncSearchableSelect.tsx—var(--color-primary-50), var(--color-primary-100), var(--color-primary-600), var(--color-gray-800)—are defined in your theme/Tailwind (tailwind.config.* or src/utils/themeColors) or add safe fallbacks.

This branch was successfully deployed

1 active deployment
Preview — 64a3804b Deployed Sep 16, 2025 by vercel[bot]
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.

1 participant

0