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 disabled state to dropdown trigger button #338

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

tho-dan
Copy link
Contributor

@tho-dan tho-dan commented Jan 10, 2025

Introduce a disabled state for the dropdown trigger button, allowing users to indicate when the dropdown is not accessible. Update documentation and examples to reflect this new feature.

Summary by CodeRabbit

  • New Features

    • Added support for disabled state in dropdown components.
    • Introduced documentation for dropdown's disabled functionality.
  • Documentation

    • Created new documentation section explaining dropdown disabled state.
    • Added example component demonstrating dropdown disabled behavior.
  • Improvements

    • Enhanced dropdown component with new disabled prop.
    • Implemented conditional disabling of dropdown trigger button.

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request introduces a disabled state functionality for the Dropdown component. The changes include adding a new disabled prop to the FwbDropdown component, creating a new example component FwbDropdownExampleDisabled.vue to demonstrate the disabled state, and updating the dropdown documentation to include information about the disabled functionality.

Changes

File Change Summary
docs/components/dropdown.md Added new section "Dropdown - Disabled" and imported FwbDropdownExampleDisabled component; updated API section to include disabled prop.
docs/components/dropdown/examples/FwbDropdownExampleDisabled.vue New example component showcasing normal and disabled dropdown states.
src/components/FwbDropdown/FwbDropdown.vue Added disabled prop to enable disabling the dropdown trigger button.

Possibly related PRs

Suggested reviewers

  • Sqrcz

Poem

🐰 A dropdown that rests, button sealed tight,
Disabled and calm, no interactive might.
A prop so simple, yet powerful too,
Controlling the flow with a gentle "can't do"!
Rabbit's code magic, making interfaces neat! 🔒


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>, please review it.
    • 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 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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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. (Beta)
  • @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

netlify bot commented Jan 10, 2025

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit 3c27fc7
🔍 Latest deploy log https://app.netlify.com/sites/sensational-seahorse-8635f8/deploys/6784c99a2d23a000080a6441
😎 Deploy Preview https://deploy-preview-338--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 site configuration.

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

🧹 Nitpick comments (2)
docs/components/dropdown/examples/FwbDropdownExampleDisabled.vue (1)

2-2: Consider adding responsive behavior to the flex layout.

The current layout might stack items incorrectly on smaller screens.

-  <div class="vp-raw flex gap-2 flex-wrap">
+  <div class="vp-raw flex flex-col sm:flex-row gap-2 flex-wrap">
docs/components/dropdown.md (1)

243-244: Enhance the disabled state documentation.

The note about manual implementation with custom triggers is important but could be more detailed.

-Please note that this has to be manually implemented when using a custom trigger (see below)
+When using a custom trigger (see below), you'll need to manually implement the disabled state by:
+1. Adding the disabled prop to your trigger element
+2. Preventing click events when disabled
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d39697 and 19dfd25.

📒 Files selected for processing (3)
  • docs/components/dropdown.md (2 hunks)
  • docs/components/dropdown/examples/FwbDropdownExampleDisabled.vue (1 hunks)
  • src/components/FwbDropdown/FwbDropdown.vue (2 hunks)
🧰 Additional context used
🪛 GitHub Check: lint (18.x)
src/components/FwbDropdown/FwbDropdown.vue

[warning] 9-9:
':color' should be on a new line

🪛 Markdownlint (0.37.0)
docs/components/dropdown.md

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-pkg (20.x)
🔇 Additional comments (3)
docs/components/dropdown/examples/FwbDropdownExampleDisabled.vue (2)

3-11: LGTM! Clear example of normal state.

The implementation effectively demonstrates the default behavior with clear, descriptive content.


12-21: LGTM! Clear example of disabled state.

The disabled state is well-implemented with appropriate descriptive content explaining the state.

src/components/FwbDropdown/FwbDropdown.vue (1)

69-69: LGTM! Proper type definition for disabled prop.

The disabled prop is correctly added to the props interface with an optional boolean type.

src/components/FwbDropdown/FwbDropdown.vue Outdated Show resolved Hide resolved
docs/components/dropdown.md Outdated Show resolved Hide resolved
docs/components/dropdown.md Outdated Show resolved Hide resolved
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.

Hey,

CodeRabbit made some good points... please amend your code according to comments below. 🙏

docs/components/dropdown.md Outdated Show resolved Hide resolved
docs/components/dropdown.md Outdated Show resolved Hide resolved
src/components/FwbDropdown/FwbDropdown.vue Outdated Show resolved Hide resolved
src/components/FwbDropdown/FwbDropdown.vue Outdated Show resolved Hide resolved
@Sqrcz Sqrcz self-assigned this Jan 11, 2025
@Sqrcz Sqrcz added the 🔧 enhancement New feature or request label Jan 11, 2025
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

🧹 Nitpick comments (1)
docs/components/dropdown.md (1)

244-244: Enhance the custom trigger note.

The note about custom trigger implementation could be more specific. Consider expanding it to:

"Please note that when using a custom trigger (via the trigger slot), you'll need to manually implement the disabled state by passing the disabled prop to your trigger element and handling the disabled state in your click handlers."

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 19dfd25 and 122388c.

📒 Files selected for processing (2)
  • docs/components/dropdown.md (3 hunks)
  • src/components/FwbDropdown/FwbDropdown.vue (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/FwbDropdown/FwbDropdown.vue
🧰 Additional context used
📓 Learnings (2)
📓 Common learnings
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#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: 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.
docs/components/dropdown.md (2)
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.
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#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.
🪛 Markdownlint (0.37.0)
docs/components/dropdown.md

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (4)
docs/components/dropdown.md (4)

6-6: LGTM!

The import statement follows the established pattern and is correctly placed.


247-260: Fix code fence and add language specifier.

Add language and highlighting to the code fence.

🧰 Tools
🪛 Markdownlint (0.37.0)

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


330-330: LGTM!

The disabled prop is correctly documented in the API section with appropriate type and default value.


243-261: Verify click handler implementation.

Based on previous learnings, ensure that the click handlers in the FwbDropdown component respect the disabled prop by adding early returns.

Let's verify the implementation:

✅ Verification successful

Implementation correctly handles disabled state ✓

The FwbDropdown component properly implements the disabled state by:

  • Adding early return in the click handler (if (props.disabled) return)
  • Passing the disabled prop to the button component
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if click handlers respect the disabled prop

# Search for click handlers in the dropdown component
ast-grep --pattern 'onClick($$$) {
  $$$
}'

# Search for disabled prop usage in click handlers
rg -A 5 'onClick.*disabled'

Length of output: 75


Script:

#!/bin/bash
# First locate the FwbDropdown component file
fd "FwbDropdown.vue"

# Then examine its contents for click handlers and disabled prop
rg -l "disabled.*prop|@click|v-on:click|onClick" $(fd "FwbDropdown.vue")

Length of output: 222


Script:

#!/bin/bash
# Get the full content focusing on click handlers and disabled prop
cat src/components/FwbDropdown/FwbDropdown.vue | grep -A 10 -B 10 "@click\|v-on:click\|onClick\|disabled"

Length of output: 2515

🧰 Tools
🪛 Markdownlint (0.37.0)

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

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

🧹 Nitpick comments (1)
docs/components/dropdown.md (1)

243-261: LGTM with a suggestion for enhancement!

The documentation clearly explains the disabled state functionality and provides a good example. The note about custom triggers is particularly valuable for implementers.

Consider adding a brief explanation of the visual and behavioral differences between normal and disabled states to help users understand what to expect.

Add a description like:

 ## Dropdown - Disabled
+When disabled, the dropdown trigger button appears grayed out and becomes non-interactive, preventing users from opening the dropdown menu.
+
 Please note that when using a custom trigger...
🧰 Tools
🪛 Markdownlint (0.37.0)

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 222c2dd and 3c27fc7.

📒 Files selected for processing (1)
  • docs/components/dropdown.md (3 hunks)
🧰 Additional context used
📓 Learnings (2)
📓 Common learnings
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#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: 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.
docs/components/dropdown.md (2)
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.
Learnt from: Sqrcz
PR: themesberg/flowbite-vue#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.
🪛 Markdownlint (0.37.0)
docs/components/dropdown.md

260-260: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (2)
docs/components/dropdown.md (2)

6-6: LGTM!

The import statement follows the established naming convention and is properly placed with other example imports.


330-330: Props table update looks good!

The disabled prop is properly documented in the API section with correct type and default value.

@tho-dan tho-dan requested a review from Sqrcz January 13, 2025 11:11
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 making additional changes 🙌

@Sqrcz Sqrcz merged commit ffee350 into themesberg:main Jan 16, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants