Skip to content

Conversation

moghaddam01
Copy link
Contributor

@moghaddam01 moghaddam01 commented Jul 14, 2025

Introduced the FwbAutocomplete component, enabling users to search and select options with real-time filtering. Added multiple examples demonstrating various functionalities, including remote data loading, custom option templates, and validation. Updated documentation to include the new component and its usage.

Summary by CodeRabbit

  • New Features

    • Introduced a fully featured, accessible autocomplete component with support for local and remote data, keyboard navigation, customizable display, validation states, and size variants.
    • Added comprehensive documentation for the autocomplete component, including multiple usage examples and detailed API references.
    • Provided several example Vue components demonstrating autocomplete usage with local options, remote data fetching, custom rendering, validation, custom input components, and size variations.
  • Tests

    • Added a complete test suite covering all major functionalities and behaviors of the autocomplete component.

Introduced the FwbAutocomplete component, enabling users to search and select options with real-time filtering. Added multiple examples demonstrating various functionalities, including remote data loading, custom option templates, and validation. Updated documentation to include the new component and its usage.
Copy link

netlify bot commented Jul 14, 2025

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit 4d8fe3c
🔍 Latest deploy log https://app.netlify.com/projects/sensational-seahorse-8635f8/deploys/688d2cce30aeb0000841e424
😎 Deploy Preview https://deploy-preview-400--sensational-seahorse-8635f8.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 project configuration.

Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Walkthrough

A new FwbAutocomplete Vue component was introduced, providing a flexible autocomplete input with local and remote filtering, keyboard navigation, and customizable UI. Extensive documentation, usage examples, type definitions, a styling composable, and a comprehensive test suite were added. The component and its types are now exported, and documentation navigation was updated.

Changes

Files / Areas Change Summary
Core component and types
src/components/FwbAutocomplete/FwbAutocomplete.vue,
src/components/FwbAutocomplete/types.ts
Added the new FwbAutocomplete component with generic props, emits, and TypeScript types for flexible autocomplete functionality.
Styling composable
src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts
Added a composable for managing and merging Tailwind CSS class names for the autocomplete component, supporting reactivity and customization.
Test suite
src/components/FwbAutocomplete/tests/Autocomplete.spec.ts
Introduced a comprehensive test suite covering all primary behaviors and edge cases of the autocomplete component, including filtering, selection, keyboard navigation, remote search, validation, and slot rendering.
Exports
src/index.ts
Exported the new FwbAutocomplete component for public use.
Documentation and navigation
docs/components/autocomplete.md,
docs/.vitepress/config.ts
Added extensive documentation for the autocomplete component, including usage, API reference, and multiple interactive examples. Registered the new Autocomplete component in the documentation sidebar navigation.
Example components
docs/components/autocomplete/examples/FwbAutocompleteExample.vue,
FwbAutocompleteExampleCustom.vue,
FwbAutocompleteExampleCustomInput.vue,
FwbAutocompleteExampleRemote.vue,
FwbAutocompleteExampleSize.vue,
FwbAutocompleteExampleValidation.vue
Added multiple Vue example components demonstrating local usage, custom rendering, custom input integration, remote fetching, size variants, and validation with the autocomplete.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FwbAutocomplete
    participant ParentComponent

    User->>FwbAutocomplete: Focuses input / types query
    FwbAutocomplete->>FwbAutocomplete: Debounces input, filters options (local or remote)
    alt Remote mode
        FwbAutocomplete->>ParentComponent: Emits "search" event with query
        ParentComponent-->>FwbAutocomplete: Updates options prop with results
    end
    FwbAutocomplete->>User: Shows filtered dropdown
    User->>FwbAutocomplete: Selects option (click/keyboard)
    FwbAutocomplete->>ParentComponent: Emits "update:modelValue" and "select" events
    FwbAutocomplete->>User: Updates input and closes dropdown
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

📚 documentation, 🔧 enhancement

Poem

🐇 Hop, hop, the code's anew,
Autocomplete brings joy to you!
With docs and tests all shining bright,
It searches near and far with light.
Custom inputs, sizes too,
A rabbit’s gift, just for you!
✨🌸🐰

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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: 9

🧹 Nitpick comments (6)
docs/components/autocomplete/examples/FwbAutocompleteExampleCustom.vue (2)

57-57: Add proper TypeScript typing for consistency.

The selectedUser ref should be typed consistently with other examples for better type safety.

Apply this diff to improve type safety:

-const selectedUser = ref(null)
+const selectedUser = ref<typeof users[0] | null>(null)

63-63: Consider using local avatar images for documentation reliability.

The external avatar URLs from pravatar.cc might not be reliable for documentation purposes and could fail in offline environments.

Consider using local placeholder images or generate simple avatar placeholders to ensure the documentation works consistently.

Also applies to: 69-69, 75-75, 81-81

docs/components/autocomplete/examples/FwbAutocompleteExampleRemote.vue (1)

75-111: Consider more specific error messages

The search function handles the API calls well with proper error handling and 404 status checks. However, the generic error message could be more informative.

Consider providing more specific error messages based on the error type:

  } catch (err) {
-    error.value = 'Failed to search countries. Please try again.'
+    error.value = err instanceof Error ? err.message : 'Failed to search countries. Please try again.'
    countries.value = []
  }
docs/components/autocomplete.md (3)

24-49: Fix markdown formatting: Add language specification

The fenced code block should specify the language for proper syntax highlighting.

-```
+```vue

114-160: Fix markdown formatting: Add language specification

The fenced code block should specify the language for proper syntax highlighting.

-```
+```vue

205-254: Fix markdown formatting: Add language specification

The fenced code block should specify the language for proper syntax highlighting.

-```
+```vue
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 570e238 and 52f7920.

📒 Files selected for processing (12)
  • docs/.vitepress/config.ts (1 hunks)
  • docs/components/autocomplete.md (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExample.vue (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExampleCustom.vue (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExampleRemote.vue (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExampleSize.vue (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExampleValidation.vue (1 hunks)
  • src/components/FwbAutocomplete/FwbAutocomplete.vue (1 hunks)
  • src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1 hunks)
  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1 hunks)
  • src/components/FwbAutocomplete/types.ts (1 hunks)
  • src/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/components/FwbAutocomplete/FwbAutocomplete.vue (1)
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#338
File: docs/components/dropdown.md:243-261
Timestamp: 2025-01-11T13:26:22.855Z
Learning: The `disabled` prop in the FwbDropdown component is a boolean prop that defaults to `false` and controls whether the dropdown trigger button is disabled.
🧬 Code Graph Analysis (1)
src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1)
src/components/FwbAutocomplete/types.ts (2)
  • AutocompleteSize (3-3)
  • ValidationStatus (4-4)
🪛 markdownlint-cli2 (0.17.2)
docs/components/autocomplete.md

49-49: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


160-160: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


218-218: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


254-254: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (18)
docs/.vitepress/config.ts (1)

68-68: LGTM! Navigation entry properly added.

The Autocomplete component entry is correctly formatted and positioned alphabetically in the form components section.

src/index.ts (1)

6-6: LGTM! Component export properly added.

The FwbAutocomplete component export follows the established pattern and is correctly positioned alphabetically.

docs/components/autocomplete/examples/FwbAutocompleteExample.vue (1)

1-37: LGTM! Well-structured basic example.

The example effectively demonstrates the core functionality of the FwbAutocomplete component with proper TypeScript typing, v-model binding, and clear user feedback.

docs/components/autocomplete/examples/FwbAutocompleteExampleSize.vue (1)

1-53: LGTM! Clear size variant demonstration.

The example effectively shows all three size variants with proper spacing, labeling, and individual v-model bindings.

docs/components/autocomplete/examples/FwbAutocompleteExampleCustom.vue (1)

10-28: Excellent custom option rendering example.

The scoped slot implementation effectively demonstrates how to customize the dropdown options with rich content including avatars, names, and emails.

docs/components/autocomplete/examples/FwbAutocompleteExampleValidation.vue (2)

1-38: LGTM: Well-structured validation example

The template demonstrates proper usage of validation slots and conditional rendering. The validation status binding and message templates are implemented correctly.


40-63: LGTM: Clean composition API implementation

The script section properly uses Vue 3 Composition API with reactive references and computed properties. The validation logic is simple but effective for demonstration purposes.

docs/components/autocomplete/examples/FwbAutocompleteExampleRemote.vue (1)

1-54: LGTM: Comprehensive remote search example

The template demonstrates proper usage of remote search features including loading states, custom option templates, and error handling. The slot customization with flag and region display is well-implemented.

docs/components/autocomplete.md (1)

256-293: LGTM: Comprehensive API documentation

The API documentation provides clear information about props, events, and slots with proper type information and descriptions. This will be helpful for developers using the component.

src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1)

38-53: LGTM: Clean utility functions

The getDropdownItemClasses function and messageClasses computed property are well-implemented and provide the expected functionality for dynamic styling.

src/components/FwbAutocomplete/types.ts (3)

1-5: LGTM: Clean type imports and exports

The imports from the input types module and re-exports are properly structured. The AutocompleteSize alias maintains consistency with the existing input component types.


6-27: LGTM: Comprehensive props interface

The AutocompleteProps interface provides a complete set of configuration options with proper generic type support. The optional properties are well-defined and the types are consistent with the component's functionality.


29-33: LGTM: Well-defined event emissions

The AutocompleteEmits interface properly defines all component events with correct type signatures. The generic type parameter ensures type safety for the option data.

src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1)

1-23: Test setup looks good!

Proper use of fake timers for testing debounced functionality.

src/components/FwbAutocomplete/FwbAutocomplete.vue (4)

199-215: Consider not clearing selection on every keystroke

The handleInput method clears the modelValue immediately when typing begins. This might be unexpected behavior - users might want to refine their search while maintaining the current selection.

Consider only clearing the selection when the user explicitly clears the input or selects a new option. This would provide a better user experience for incremental search refinement.


160-176: Well-implemented filtering logic!

The filtering implementation properly handles edge cases with optional chaining and nullish coalescing. Good defensive programming.


222-257: Excellent keyboard navigation implementation!

The keyboard handling is comprehensive with proper wrapping behavior and event prevention.


280-289: Proper lifecycle management and cleanup!

Good practice with removing event listeners and clearing timers on unmount.

@moghaddam01
Copy link
Contributor Author

moghaddam01 commented Jul 14, 2025

Hello guys! can you please review?

Thanks! @wazeerc , @andreyjamer, @Sqrcz , @zoltanszogyenyi

Copy link
Contributor

@wazeerc wazeerc left a comment

Choose a reason for hiding this comment

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

Looking good, @Sqrcz will approve if aok

@andreyjamer
Copy link
Contributor

@moghaddam01 I looks nice, great job! But what I personally don't like is that the implementation is strictly tied to the input implementation. I mean internally it has the input that couldn't be customized. For example it is impossible to use prefix for icon instead of suffix. It is impossible to use a custom icon (from external icons set like fontawesome or something like this).

Wouldn't it be better to pass the input to the slot of the component? Then developers will have a possibility to manage input appearance. And the only responsibility of the autocomplete will be to manage the list of options.

Another thing that bothers me a little bit is the fact that the list is displayed using position: absolute. It may cause issues in some cases. For example if the block below the autocomplete has z-index more than 50.
image
It is minor, but still could be the problem for some users.
May be using teleport + position: fixed looks better in this case. But it will cause more complex logic to track and update the position of the list related to the input.

@moghaddam01
Copy link
Contributor Author

Thanks for your input @andreyjamer!
good catch and great comments!
I will fix them.

@moghaddam01
Copy link
Contributor Author

moghaddam01 commented Jul 18, 2025

Just pushed new commit , now the autocomplete component provides maximum flexibility by allowing you to use any Vue input component (default to FwbInput) through the inputComponent and inputProps props.

@andreyjamer

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

🔭 Outside diff range comments (1)
docs/components/autocomplete/examples/FwbAutocompleteExampleCustomInput.vue (1)

273-274: Missing closing tag.

The script tag appears to be missing its closing tag.

-</script>
-274
+</script>
🧹 Nitpick comments (5)
docs/components/autocomplete.md (4)

25-50: Address markdown formatting issue.

The static analysis correctly identified a missing language specification for the code block.

-```
+```vue
 <template>
   <fwb-autocomplete
     v-model="selectedCountry"

158-204: Fix markdown formatting issue.

Missing language specification for the code block as flagged by static analysis.

-```
+```vue
 <template>
   <fwb-autocomplete
     v-model="selectedUser"

249-298: Fix markdown formatting issue.

Missing language specification for the code block.

-```
+```vue
 <template>
   <div class="space-y-4">
     <fwb-autocomplete

362-401: Fix heading level increment issue.

The static analysis correctly identified that heading levels should only increment by one level at a time.

-#### Basic Usage
+### Basic Usage

Also fix the missing language specification:

-```
+```vue
 <fwb-autocomplete
   v-model="selected"
docs/components/autocomplete/examples/FwbAutocompleteExampleCustomInput.vue (1)

171-175: Consider import path structure.

The import from ../../../../src/index suggests this example is tightly coupled to the source structure. Consider if this could be made more maintainable.

-import { FwbAutocomplete } from '../../../../src/index'
+import { FwbAutocomplete } from 'flowbite-vue'

This would make the example more consistent with how users would actually import the component, though I understand this might be necessary for the documentation build process.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bacf10 and f97e2e0.

📒 Files selected for processing (5)
  • docs/components/autocomplete.md (1 hunks)
  • docs/components/autocomplete/examples/FwbAutocompleteExampleCustomInput.vue (1 hunks)
  • src/components/FwbAutocomplete/FwbAutocomplete.vue (1 hunks)
  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1 hunks)
  • src/components/FwbAutocomplete/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/FwbAutocomplete/types.ts
  • src/components/FwbAutocomplete/FwbAutocomplete.vue
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/components/autocomplete.md

50-50: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


204-204: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


262-262: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


298-298: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🔇 Additional comments (8)
docs/components/autocomplete.md (3)

1-8: Documentation setup looks good.

The script setup properly imports all example components and follows Vue 3 composition API patterns.


112-154: Excellent documentation of custom input flexibility.

The custom input components section clearly demonstrates the component's flexibility and provides practical examples. The table format for props is well-organized and informative.


300-361: Comprehensive API documentation.

The API section provides excellent coverage of all props, events, and slots with clear descriptions and type information. This will be very helpful for developers using the component.

docs/components/autocomplete/examples/FwbAutocompleteExampleCustomInput.vue (5)

1-10: Clean template structure.

The template is well-organized with clear sections and proper semantic HTML structure.


12-77: Excellent demonstration of custom input flexibility.

This example effectively showcases the component's ability to accept custom input components, addressing one of the design concerns mentioned in the PR feedback. The custom suffix slot with loading states and clear functionality is well-implemented.


90-158: Good example of input customization.

The second example shows how to customize the default FwbInput with props, providing an alternative approach to the custom input component method.


177-241: Well-designed custom input component.

The custom input implementation is comprehensive and demonstrates advanced Vue 3 patterns:

  • Proper prop definitions with TypeScript
  • Correct event handling and emission
  • Dynamic class composition
  • Render function usage with h()
  • Accessible SVG icons with proper attributes

This addresses the PR feedback about input customization limitations by showing how developers can create fully custom input components.


258-272: Clean TypeScript usage and state management.

Good use of TypeScript for type safety and proper reactive state management with the composition API. The mock search function with timeout appropriately simulates real-world async behavior.

@moghaddam01 moghaddam01 requested a review from wazeerc July 18, 2025 06:34
@Sqrcz Sqrcz self-assigned this Jul 19, 2025
@Sqrcz Sqrcz added the 📦 new component New component implementation label Jul 19, 2025
@Sqrcz
Copy link
Collaborator

Sqrcz commented Jul 19, 2025

Thanks for your contribution! Awesome piece of work 🙌

I noticed that you're calling twMerge directly with class names. For consistency and flexibility, please use our useMergeClasses composable instead.
It's not used everywhere yet... but it's the way forward ;)

Why?

  • useMergeClasses supports strings, arrays, and objects (including nested/conditional values), just like Vue’s :class binding.
  • It normalizes all inputs to a single string and then merges with twMerge, so you never have to worry about formatting or shape.
  • This makes components simpler and more robust—developers can always pass any supported class input without extra handling.

Example in FwbInput

This approach also keeps class normalization logic centralized and consistent across the codebase.

Thanks for updating this!

Linter warns about few unused variables... but I wasn't able to check it properly yet... I'll play around a bit more with it on Monday and give you a proper update.

Overall, this looks solid! 👌

@moghaddam01
Copy link
Contributor Author

Hi @Sqrcz, thanks for your comments!
Sure, I’ll take care of it.

Here’s the checklist:

Fix the z-index issue by retrieving both manual and auto values to set the highest available one.

Replace twMerge with useMergeClasses.

Let me know if I missed anything.

@Sqrcz
Copy link
Collaborator

Sqrcz commented Jul 23, 2025

Hej @moghaddam01,

Thanks for your patience! I took some time to test the new component properly.

Please update the PR according to your checklist.

Additionally, I noticed a small issue in the documentation. In examples the search-fields prop is currently set as a string (search-fields="name'"), but it should be an array (even if it contains only a single string) for it to work correctly.

Once these fixes are applied, I believe the PR will be ready for merging.

For the next iteration we can think about making a multiselect out of it ;)

Thanks for your work on this!

@Sqrcz
Copy link
Collaborator

Sqrcz commented Jul 24, 2025

@moghaddam01

please take a look at one more thing...

when you tab in to this field... dropdown appears... when you tab out of it... dropdown stays... (it disappears when you click somewhere outside), but it should hide on blur.

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: 2

🧹 Nitpick comments (2)
docs/components/autocomplete.md (2)

124-131: Keep prop casing consistent (inputComponent vs input-component)

Everywhere else, the docs adopt camelCase (inputComponent). Mixing kebab-case here may confuse users, especially TS users relying on autocomplete.

-    :input-component="CustomInput"
+    :inputComponent="CustomInput"

Same for the second example below.


148-152: Table header mismatch with actual prop name

The table lists inputComponent/inputProps correctly, but the first column is titled Prop whereas earlier tables use Name. Stick to one convention to avoid lint noise and keep auto-generated TOCs clean.

-| Prop | Type | Default | Description |
+| Name | Type | Default | Description |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f782c71 and 7d27f1c.

📒 Files selected for processing (1)
  • docs/components/autocomplete.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/components/autocomplete.md

50-50: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


204-204: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


262-262: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


298-298: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


375-375: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🔇 Additional comments (1)
docs/components/autocomplete.md (1)

24-26: Add explicit language identifiers to all fenced code blocks

Several blocks (detected by markdownlint MD040) open with ````` but omit the language tag, losing syntax highlighting.

-```
+```vue

Applies to the blocks following the component demo lines in “Default”, “Remote Data with Debounce”, “Custom Option Template”, and “Validation” sections.

Also applies to: 52-56, 157-161, 206-210

Comment on lines +90 to +98
const searchCountries = async (query) => {
loading.value = true
try {
const response = await fetch(`https://restcountries.com/v3.1/name/${query}`)
const data = await response.json()

countries.value = data.slice(0, 10).map(country => ({
name: country.name.common,
capital: country.capital?.[0] || 'N/A',
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Encode the query to prevent malformed‐URL errors

searchCountries interpolates the user’s raw query directly into the URL.
Spaces or non-ASCII chars will break the request (404 from RestCountries).

-    const response = await fetch(`https://restcountries.com/v3.1/name/${query}`)
+    const response = await fetch(
+      `https://restcountries.com/v3.1/name/${encodeURIComponent(query)}`
+    )

Consider also checking response.ok before response.json() to surface HTTP errors clearly.

📝 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.

Suggested change
const searchCountries = async (query) => {
loading.value = true
try {
const response = await fetch(`https://restcountries.com/v3.1/name/${query}`)
const data = await response.json()
countries.value = data.slice(0, 10).map(country => ({
name: country.name.common,
capital: country.capital?.[0] || 'N/A',
const searchCountries = async (query) => {
loading.value = true
try {
const response = await fetch(
`https://restcountries.com/v3.1/name/${encodeURIComponent(query)}`
)
const data = await response.json()
countries.value = data.slice(0, 10).map(country => ({
name: country.name.common,
capital: country.capital?.[0] || 'N/A',
🤖 Prompt for AI Agents
In docs/components/autocomplete.md around lines 90 to 98, the searchCountries
function directly inserts the raw query into the URL, which can cause
malformed-URL errors with spaces or special characters. Fix this by encoding the
query parameter using encodeURIComponent before including it in the fetch URL.
Additionally, add a check for response.ok before calling response.json() to
handle HTTP errors explicitly and improve error reporting.

Comment on lines +248 to +281
<fwb-autocomplete-example-size />
```vue
<template>
<div class="space-y-4">
<fwb-autocomplete
v-model="selected1"
:options="countries"
:search-fields="['name']"
display="name"
label="Small"
size="sm"
placeholder="Small autocomplete..."
/>

<fwb-autocomplete
v-model="selected2"
:options="countries"
:search-fields="['name']"
display="name"
label="Medium (default)"
size="md"
placeholder="Medium autocomplete..."
/>

<fwb-autocomplete
v-model="selected3"
:options="countries"
:search-fields="['name']"
display="name"
label="Large"
size="lg"
placeholder="Large autocomplete..."
/>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix indented code block – markdownlint MD046

The “Sizes” example is rendered as an indented block instead of fenced, breaking syntax highlighting and copy-paste.

-    <fwb-autocomplete
-      v-model="selected1"
-      :options="countries"
-
-    />
+```vue
+<fwb-autocomplete
+  v-model="selected1"
+  :options="countries"
+
+/>
+``` 

Repeat for the medium and large instances inside the same snippet.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

262-262: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)

🤖 Prompt for AI Agents
In docs/components/autocomplete.md between lines 248 and 281, the Vue code
snippet for the "Sizes" example is incorrectly formatted as an indented block
instead of a fenced code block, causing issues with syntax highlighting and
copy-paste. To fix this, replace the indented code block with a fenced code
block using triple backticks before and after the entire Vue template, ensuring
all three <fwb-autocomplete> instances are inside the fenced block with proper
indentation.

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

♻️ Duplicate comments (4)
docs/components/autocomplete.md (2)

90-98: Encode the query to prevent malformed-URL errors

searchCountries interpolates the user's raw query directly into the URL.
Spaces or non-ASCII chars will break the request (404 from RestCountries).

-    const response = await fetch(`https://restcountries.com/v3.1/name/${query}`)
+    const response = await fetch(
+      `https://restcountries.com/v3.1/name/${encodeURIComponent(query)}`
+    )

Consider also checking response.ok before response.json() to surface HTTP errors clearly.


248-281: Fix indented code block – markdownlint MD046

The "Sizes" example is rendered as an indented block instead of fenced, breaking syntax highlighting and copy-paste.

-    <fwb-autocomplete
-      v-model="selected1"
-      :options="countries"
-
-    />
+```vue
+<fwb-autocomplete
+  v-model="selected1"
+  :options="countries"
+
+/>
+```

Repeat for the medium and large instances inside the same snippet.

src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1)

20-36: Handle Record<string, boolean> class types

The computed functions only handle string types from class props, but the interface allows Record<string, boolean> which is not being processed.

 const wrapperClasses = computed(() => {
   return useMergeClasses([
     baseWrapperClasses,
-    typeof props.wrapperClass?.value === 'string' ? props.wrapperClass.value : '',
+    props.wrapperClass?.value || '',
   ])
 })
 const dropdownClasses = computed(() => {
   return useMergeClasses([
     baseDropdownClasses.value,
-    typeof props.dropdownClass?.value === 'string' ? props.dropdownClass.value : '',
+    props.dropdownClass?.value || '',
   ])
 })

The useMergeClasses function already handles normalization of different class input types including objects, so just pass the value directly.

src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1)

422-427: Remove conditional to ensure test reliability

 const firstOption = wrapper.find('[data-testid="fwb-autocomplete-option-0"]')
-if (firstOption.exists()) {
-  await firstOption.trigger('click')
-
-  // Input should show the selected option's display value
-  expect(input.element.value).toBe('United States')
-}
+expect(firstOption.exists()).toBe(true)
+await firstOption.trigger('click')
+
+// Input should show the selected option's display value
+expect(input.element.value).toBe('United States')
🧹 Nitpick comments (1)
docs/components/autocomplete.md (1)

363-376: Fix heading level increment

The heading jumps from h2 to h4, violating markdown best practices.

-#### Basic Usage
+### Basic Usage
-#### Remote Data with Custom Input Props
+### Remote Data with Custom Input Props
-#### Custom Input Component
+### Custom Input Component
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d27f1c and 6e7258d.

📒 Files selected for processing (5)
  • docs/components/autocomplete.md (1 hunks)
  • src/components/FwbAutocomplete/FwbAutocomplete.vue (1 hunks)
  • src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1 hunks)
  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1 hunks)
  • src/components/FwbAutocomplete/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/FwbAutocomplete/types.ts
🧰 Additional context used
🧠 Learnings (3)
src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1)

Learnt from: Sqrcz
PR: #389
File: src/components/FwbToggle/FwbToggle.vue:0-0
Timestamp: 2025-07-18T12:11:01.047Z
Learning: In the FwbToggle component, the toggleBallClasses variable name is misleading - it doesn't style the actual toggle ball/thumb, but rather the label text container. The visual toggle ball is rendered through other means (likely CSS on the toggle track or pseudo-elements).

src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (2)

Learnt from: Sqrcz
PR: #338
File: docs/components/dropdown.md:243-261
Timestamp: 2025-01-11T13:26:22.855Z
Learning: The disabled prop in the FwbDropdown component is a boolean prop that defaults to false and controls whether the dropdown trigger button is disabled.

Learnt from: Sqrcz
PR: #389
File: src/components/FwbToggle/FwbToggle.vue:0-0
Timestamp: 2025-07-18T12:11:01.047Z
Learning: In the FwbToggle component, the toggleBallClasses variable name is misleading - it doesn't style the actual toggle ball/thumb, but rather the label text container. The visual toggle ball is rendered through other means (likely CSS on the toggle track or pseudo-elements).

src/components/FwbAutocomplete/FwbAutocomplete.vue (2)

Learnt from: Sqrcz
PR: #338
File: src/components/FwbDropdown/FwbDropdown.vue:9-9
Timestamp: 2025-01-11T13:26:22.708Z
Learning: In Vue components with disabled states, ensure click handlers respect the disabled prop by adding early returns (e.g., if (props.disabled) return). The disabled attribute alone on elements isn't sufficient as the click handler can still execute.

Learnt from: Sqrcz
PR: #389
File: src/components/FwbToggle/FwbToggle.vue:0-0
Timestamp: 2025-07-18T12:11:01.047Z
Learning: In the FwbToggle component, the toggleBallClasses variable name is misleading - it doesn't style the actual toggle ball/thumb, but rather the label text container. The visual toggle ball is rendered through other means (likely CSS on the toggle track or pseudo-elements).

🧬 Code Graph Analysis (1)
src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts (1)
src/composables/useMergeClasses.ts (1)
  • useMergeClasses (27-29)
🪛 markdownlint-cli2 (0.17.2)
docs/components/autocomplete.md

50-50: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


204-204: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


262-262: Code block style
Expected: fenced; Actual: indented

(MD046, code-block-style)


298-298: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


376-376: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🔇 Additional comments (2)
src/components/FwbAutocomplete/FwbAutocomplete.vue (2)

111-114: Well-implemented dropdown state management

The use of isSelectingOption flag with mousedown/mouseup/mouseleave events effectively prevents the dropdown from closing during option selection, solving the common blur/click race condition.

Also applies to: 271-274


330-344: Robust scroll handling implementation

Good defensive programming by checking if scrollIntoView is a function before calling it, ensuring compatibility across different environments.

Comment on lines +27 to +29
const baseDropdownClasses = computed(() =>
`absolute z-[${props.zIndex?.value}] w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg shadow-lg max-h-60 overflow-y-auto`,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid dynamic Tailwind class generation

Using template literals to generate Tailwind classes like z-[${props.zIndex?.value}] is problematic because Tailwind's purge mechanism won't detect these dynamically generated classes.

Use inline styles for dynamic values instead:

-const baseDropdownClasses = computed(() =>
-  `absolute z-[${props.zIndex?.value}] w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg shadow-lg max-h-60 overflow-y-auto`,
-)
+const baseDropdownClasses = 'absolute w-full mt-1 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg shadow-lg max-h-60 overflow-y-auto'

Then apply z-index as an inline style in the component template:

<div :class="dropdownClasses" :style="{ zIndex: zIndex }">
🤖 Prompt for AI Agents
In src/components/FwbAutocomplete/composables/useAutocompleteClasses.ts around
lines 27 to 29, avoid using template literals to dynamically generate Tailwind
classes like z-[${props.zIndex?.value}] because Tailwind's purge mechanism
cannot detect them. Instead, remove the dynamic z-index class from the computed
class string and apply the z-index value as an inline style in the component
template by binding :style="{ zIndex: props.zIndex?.value }" alongside the
static classes.

Comment on lines +89 to +94
if (firstOption.exists()) {
await firstOption.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
expect(wrapper.emitted('select')).toBeTruthy()
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove conditional to ensure test reliability

The conditional could cause the test to pass even when no dropdown items are found.

 const firstOption = wrapper.find('[data-testid="fwb-autocomplete-option-0"]')
-if (firstOption.exists()) {
-  await firstOption.trigger('click')
-  expect(wrapper.emitted('update:modelValue')).toBeTruthy()
-  expect(wrapper.emitted('select')).toBeTruthy()
-}
+expect(firstOption.exists()).toBe(true)
+await firstOption.trigger('click')
+expect(wrapper.emitted('update:modelValue')).toBeTruthy()
+expect(wrapper.emitted('select')).toBeTruthy()
📝 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.

Suggested change
if (firstOption.exists()) {
await firstOption.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
expect(wrapper.emitted('select')).toBeTruthy()
}
})
const firstOption = wrapper.find('[data-testid="fwb-autocomplete-option-0"]')
expect(firstOption.exists()).toBe(true)
await firstOption.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
expect(wrapper.emitted('select')).toBeTruthy()
})
🤖 Prompt for AI Agents
In src/components/FwbAutocomplete/tests/Autocomplete.spec.ts around lines 89 to
94, remove the conditional check that verifies if firstOption.exists() before
triggering the click and asserting emitted events. This ensures the test always
attempts to click the first option and properly fails if no dropdown items are
present, improving test reliability.

Comment on lines +399 to +405
if (secondOption.exists()) {
await secondOption.trigger('mouseenter')

// Check that the option is highlighted (this would be internal state)
// We can verify by checking classes or other visual indicators
expect(secondOption.classes()).toContain('fwb-autocomplete-option')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove conditional and improve assertion

The test only verifies that a CSS class exists but doesn't actually verify highlighting behavior.

 const secondOption = wrapper.find('[data-testid="fwb-autocomplete-option-1"]')
-if (secondOption.exists()) {
-  await secondOption.trigger('mouseenter')
-
-  // Check that the option is highlighted (this would be internal state)
-  // We can verify by checking classes or other visual indicators
-  expect(secondOption.classes()).toContain('fwb-autocomplete-option')
-}
+expect(secondOption.exists()).toBe(true)
+await secondOption.trigger('mouseenter')
+
+// Verify the option has highlight styling
+expect(secondOption.classes()).toContain('bg-blue-50')
📝 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.

Suggested change
if (secondOption.exists()) {
await secondOption.trigger('mouseenter')
// Check that the option is highlighted (this would be internal state)
// We can verify by checking classes or other visual indicators
expect(secondOption.classes()).toContain('fwb-autocomplete-option')
}
const secondOption = wrapper.find('[data-testid="fwb-autocomplete-option-1"]')
expect(secondOption.exists()).toBe(true)
await secondOption.trigger('mouseenter')
// Verify the option has highlight styling
expect(secondOption.classes()).toContain('bg-blue-50')
🤖 Prompt for AI Agents
In src/components/FwbAutocomplete/tests/Autocomplete.spec.ts between lines 399
and 405, remove the conditional check for secondOption.exists() to ensure the
test always runs. Replace the current assertion that only checks for the
presence of a CSS class with a more specific assertion that verifies the option
is actually highlighted, such as checking for a distinct highlight class or
style that indicates the option is selected or focused.

@moghaddam01
Copy link
Contributor Author

moghaddam01 commented Jul 24, 2025

Hi guys – pushed some new commits covering all your inputs:

  • Autocomplete now more flexible: supports any Vue input + its props
  • Replaced direct twMerge calls with useMergeClasses for consistency
  • Fixed search-fields prop in docs: must be an array, not a string
  • Dropdown now hides on blur
  • Added autoscroll to highlighted item when navigating via keyboard (new improvement)

Thanks for all your valuable inputs and comments!
@andreyjamer @Sqrcz @wazeerc

@moghaddam01
Copy link
Contributor Author

Any update? @Sqrcz

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: 1

♻️ Duplicate comments (3)
src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (3)

89-94: Remove conditional to ensure test reliability.

The conditional could cause the test to pass even when no dropdown items are found.

 const firstOption = wrapper.find('[data-testid="fwb-autocomplete-option-0"]')
-if (firstOption.exists()) {
-  await firstOption.trigger('click')
-  expect(wrapper.emitted('update:modelValue')).toBeTruthy()
-  expect(wrapper.emitted('select')).toBeTruthy()
-}
+expect(firstOption.exists()).toBe(true)
+await firstOption.trigger('click')
+expect(wrapper.emitted('update:modelValue')).toBeTruthy()
+expect(wrapper.emitted('select')).toBeTruthy()

399-405: Remove conditional and improve assertion.

The test only verifies that a CSS class exists but doesn't actually verify highlighting behavior.

 const secondOption = wrapper.find('[data-testid="fwb-autocomplete-option-1"]')
-if (secondOption.exists()) {
-  await secondOption.trigger('mouseenter')
-
-  // Check that the option is highlighted (this would be internal state)
-  // We can verify by checking classes or other visual indicators
-  expect(secondOption.classes()).toContain('fwb-autocomplete-option')
-}
+expect(secondOption.exists()).toBe(true)
+await secondOption.trigger('mouseenter')
+
+// Verify the option has highlight styling
+expect(secondOption.classes()).toContain('bg-blue-50')

422-427: Remove conditional to ensure test reliability.

The conditional could cause the test to pass even when no dropdown items are found.

 const firstOption = wrapper.find('[data-testid="fwb-autocomplete-option-0"]')
-if (firstOption.exists()) {
-  await firstOption.trigger('click')
-
-  // Input should show the selected option's display value
-  expect(input.element.value).toBe('United States')
-}
+expect(firstOption.exists()).toBe(true)
+await firstOption.trigger('click')
+
+// Input should show the selected option's display value
+expect(input.element.value).toBe('United States')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7258d and 4d8fe3c.

📒 Files selected for processing (1)
  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: the `disabled` prop in the fwbdropdown component is a boolean prop that defaults to `false` and cont...
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#338
File: docs/components/dropdown.md:243-261
Timestamp: 2025-01-11T13:26:22.855Z
Learning: The `disabled` prop in the FwbDropdown component is a boolean prop that defaults to `false` and controls whether the dropdown trigger button is disabled.

Applied to files:

  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts
📚 Learning: in the fwbtoggle component, the `toggleballclasses` variable name is misleading - it doesn't style t...
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#389
File: src/components/FwbToggle/FwbToggle.vue:0-0
Timestamp: 2025-07-18T12:11:01.047Z
Learning: In the FwbToggle component, the `toggleBallClasses` variable name is misleading - it doesn't style the actual toggle ball/thumb, but rather the label text container. The visual toggle ball is rendered through other means (likely CSS on the toggle track or pseudo-elements).

Applied to files:

  • src/components/FwbAutocomplete/tests/Autocomplete.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: build-pkg (18.x)
  • GitHub Check: build-types (20.x)
  • GitHub Check: build-pkg (20.x)
  • GitHub Check: lint (18.x)
  • GitHub Check: docs-build (22.x)
  • GitHub Check: docs-build (20.x)
  • GitHub Check: docs-build (18.x)
🔇 Additional comments (23)
src/components/FwbAutocomplete/tests/Autocomplete.spec.ts (23)

1-23: LGTM! Well-structured test setup.

The imports, mock data, and fake timer setup/teardown are properly configured for comprehensive component testing.


24-37: LGTM! Clean basic rendering test.

The test properly verifies that basic props are rendered correctly in the component.


39-56: LGTM! Comprehensive filtering test.

The test effectively verifies both positive and negative filtering results with proper async handling.


58-72: LGTM! Proper dropdown visibility test.

The test correctly verifies that the dropdown appears on input focus using reliable data-testid selectors.


96-113: LGTM! Solid keyboard navigation test.

The test properly verifies keyboard navigation functionality without conditional checks that could hide failures.


134-151: LGTM! Comprehensive loading state test.

The test thoroughly verifies loading state rendering including text, spinner, and message elements using reliable selectors.


153-169: LGTM! Effective no results test.

The test properly verifies the no results state by simulating a search with no matches and checking for the appropriate message and element.


171-194: LGTM! Excellent debounce testing.

The test effectively uses fake timers to verify debounce behavior, ensuring search events are properly delayed and then emitted with correct parameters.


196-210: LGTM! Proper slot testing.

The test effectively verifies that validation message slots are rendered correctly with appropriate content and elements.


212-225: LGTM! Consistent slot testing.

The test properly verifies helper text slot rendering following the same reliable pattern as other slot tests.


227-239: LGTM! Proper prop passing test.

The test effectively verifies that size props are correctly passed to the child FwbInput component.


241-251: LGTM! Clear disabled state test.

The test directly verifies that the disabled prop is properly applied to the input element.


253-271: LGTM! Effective keyboard interaction test.

The test properly verifies that the Escape key closes the dropdown, checking both the open and closed states.


273-288: LGTM! Comprehensive multi-field search test.

The test effectively verifies that searching works across multiple fields by searching for a code that matches a country.


290-304: LGTM! Proper function mocking test.

The test effectively uses vi.fn() to verify that custom display functions are called with the correct parameters.


306-337: LGTM! Comprehensive valueField test.

The test thoroughly verifies that options render and select correctly when valueField is specified, with proper event emission verification.


339-369: LGTM! Complete default behavior test.

The test effectively verifies that the component works correctly without valueField, maintaining proper selection and emission behavior.


371-383: LGTM! Clear focus event test.

The test properly verifies that search events are emitted when the input receives focus.


430-450: LGTM! Proper blur behavior test.

The test effectively verifies that the dropdown closes on blur, checking both open and closed states with proper async handling.


452-472: LGTM! Thorough props passing test.

The test effectively verifies that inputProps are correctly passed to the child FwbInput component with proper object matching.


474-485: LGTM! Clear default component test.

The test properly verifies that FwbInput is used as the default input component.


487-504: LGTM! Effective z-index customization test.

The test properly verifies that custom z-index values are applied to the dropdown with the correct CSS class.


506-522: LGTM! Complete z-index testing.

The test properly verifies that the default z-index is applied when no custom value is specified, providing comprehensive z-index coverage.

Comment on lines +126 to +131
if (clearButton.exists()) {
await clearButton.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
const emittedEvents = wrapper.emitted('update:modelValue') as Array<any>
expect(emittedEvents[emittedEvents.length - 1][0]).toBe(null)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove conditional to ensure test reliability.

The conditional could cause the test to pass even when the clear button is not found.

 const clearButton = wrapper.find('[data-testid="fwb-autocomplete-clear-button"]')
-if (clearButton.exists()) {
-  await clearButton.trigger('click')
-  expect(wrapper.emitted('update:modelValue')).toBeTruthy()
-  const emittedEvents = wrapper.emitted('update:modelValue') as Array<any>
-  expect(emittedEvents[emittedEvents.length - 1][0]).toBe(null)
-}
+expect(clearButton.exists()).toBe(true)
+await clearButton.trigger('click')
+expect(wrapper.emitted('update:modelValue')).toBeTruthy()
+const emittedEvents = wrapper.emitted('update:modelValue') as Array<any>
+expect(emittedEvents[emittedEvents.length - 1][0]).toBe(null)
📝 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.

Suggested change
if (clearButton.exists()) {
await clearButton.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
const emittedEvents = wrapper.emitted('update:modelValue') as Array<any>
expect(emittedEvents[emittedEvents.length - 1][0]).toBe(null)
}
const clearButton = wrapper.find('[data-testid="fwb-autocomplete-clear-button"]')
expect(clearButton.exists()).toBe(true)
await clearButton.trigger('click')
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
const emittedEvents = wrapper.emitted('update:modelValue') as Array<any>
expect(emittedEvents[emittedEvents.length - 1][0]).toBe(null)
🤖 Prompt for AI Agents
In src/components/FwbAutocomplete/tests/Autocomplete.spec.ts around lines 126 to
131, remove the if conditional that checks if clearButton.exists() so the test
always attempts to trigger the click on the clear button. This ensures the test
fails if the clear button is not found, improving test reliability by not
silently passing when the button is missing.

Copy link
Collaborator

@Sqrcz Sqrcz left a comment

Choose a reason for hiding this comment

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

Awesome, thank you for all the updates.

Great work. 👍

@Sqrcz Sqrcz merged commit 4fe5eca into themesberg:main Aug 1, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 new component New component implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants