Skip to content

Conversation

ChrisWSchultz
Copy link
Contributor

@ChrisWSchultz ChrisWSchultz commented Aug 6, 2025

The FwbInput input element is missing a id/for connection with the label element.
There are divs wrapping the input element, so the label can't be used to wrap.
As a side-effect this also fixes the FwbAutocomplete label as well.

Please let me know if/what changes I need to make. Thank you!


src/components/FwbInput/FwbInput.vue

  • added a :for on the label element
  • changed the input v-bind to use inputAttributes
  • import and use useInputAttributes
  • moved the InputProps interface the the types.ts file

src/components/FwbInput/composables/useInputAttributes.ts

  • created useInputAttributes to:
    1. dynamically create an id for the input field based on the provided label
    2. preserve all attrs passed to the FwbInput component
    3. prevent a null/undefined id getting left on the input element. the simpler solution to this bug is to add an :id and :for on the input and label, but if no label is given there is a null/undefined id left on the input
    4. export the created inputId for use in the label :for attribute

src/components/FwbInput/types.ts

  • moved the InputProps interface to be able to import it in useInputAttributes

docs/components/input.md

  • added the autocomplete prop to the input component docs

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for an autocomplete option to the input component, allowing users to control browser autocomplete behavior.
    • Improved association between input fields and their labels for better accessibility.
  • Documentation

    • Updated input component documentation to include the new autocomplete option and clarified prop types for consistency.
…or the input element if a label prop has been passed and is not an empty string. preserves any attrs passed to fwb-input. lowercased, trimmed and replaced spaces on the label to create an id. updated the docs to include the autocomplete prop. moved the InputProps interface to the FwbInput/types file
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

This change refactors the FwbInput component by introducing a new composable for managing input attributes and label associations, updates the props typing via a centralized interface, and documents the new autocomplete prop. The documentation and typings are updated for consistency and clarity.

Changes

Cohort / File(s) Change Summary
Documentation Update
docs/components/input.md
Updated documentation to add and describe the new autocomplete prop for FwbInput; improved type formatting.
Component Refactor
src/components/FwbInput/FwbInput.vue
Refactored to use useInputAttributes composable for attribute and label handling; imports InputProps from types.
Composable Addition
src/components/FwbInput/composables/useInputAttributes.ts
Added new composable to generate input attributes and label IDs based on props and attributes.
Type Definitions
src/components/FwbInput/types.ts
Introduced InputProps interface to formalize and centralize input component props.

Sequence Diagram(s)

sequenceDiagram participant ParentComponent participant FwbInput participant useInputAttributes ParentComponent->>FwbInput: Passes props and attributes FwbInput->>useInputAttributes: Calls with props useInputAttributes-->>FwbInput: Returns inputId, inputAttributes FwbInput->>FwbInput: Binds inputAttributes to <input>, inputId to <label> 
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

🔧 enhancement

Suggested reviewers

  • Sqrcz

Poem

In the garden of code where inputs grow,
A bunny refactors, making attributes flow.
With composables fresh and types in a row,
Autocomplete joins the show!
Docs are updated, the carrots align—
Hop, hop, hooray, the input’s divine! 🥕✨

Note

⚡️ Unit Test Generation is now available in beta!

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


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b5ef124 and a34284b.

📒 Files selected for processing (1)
  • src/components/FwbInput/composables/useInputAttributes.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/FwbInput/composables/useInputAttributes.ts
✨ 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.
  • 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.

Support

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

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

netlify bot commented Aug 6, 2025

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit a34284b
🔍 Latest deploy log https://app.netlify.com/projects/sensational-seahorse-8635f8/deploys/68931330d487690008472577
😎 Deploy Preview https://deploy-preview-405--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 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

🧹 Nitpick comments (1)
src/components/FwbInput/composables/useInputAttributes.ts (1)

9-18: Consider making inputId reactive for consistency.

The inputAttributes computed works correctly, but inputId should also be computed to ensure reactivity when the label prop changes.

- const inputId = props?.label && props.label !== '' ? props.label.toLowerCase().trim().replace(/ /g, '-') : '' + const inputId = computed(() => props?.label && props.label !== '' ? props.label.toLowerCase().trim().replace(/ /g, '-') : '') const inputAttributes = computed(() => { - if (inputId !== '') { + if (inputId.value !== '') { return { ...attrs, - id: inputId, + id: inputId.value, } } else { return attrs } })
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 16fb867 and 2bd0311.

📒 Files selected for processing (4)
  • docs/components/input.md (1 hunks)
  • src/components/FwbInput/FwbInput.vue (4 hunks)
  • src/components/FwbInput/composables/useInputAttributes.ts (1 hunks)
  • src/components/FwbInput/types.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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. 
📚 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:

  • docs/components/input.md
🧬 Code Graph Analysis (1)
src/components/FwbInput/composables/useInputAttributes.ts (1)
src/components/FwbInput/types.ts (1)
  • InputProps (8-20)
🔇 Additional comments (5)
src/components/FwbInput/types.ts (1)

8-20: Well-designed centralized interface.

The InputProps interface effectively centralizes all input component properties with appropriate optional typing. The use of existing types like CommonAutoFill, InputSize, InputType, and ValidationStatus maintains consistency across the codebase.

docs/components/input.md (1)

257-263: Documentation accurately reflects the new autocomplete prop.

The addition of the autocomplete prop documentation is consistent with the interface definition and follows the established documentation format.

src/components/FwbInput/FwbInput.vue (3)

5-5: Excellent accessibility improvement with label association.

The :for="inputId" binding properly connects the label to the input element, addressing the core accessibility issue mentioned in the PR objectives.


50-53: Clean refactor with proper composable integration.

The integration of useInputAttributes composable and centralized InputProps type creates a more maintainable architecture while successfully addressing the label/input association issue.

Also applies to: 84-84


16-22: No attribute duplication risk: autocomplete is a prop, not included in inputAttributes
Since inheritAttrs: false and autocomplete is declared in defineProps, useAttrs() will strip out any prop‐named attributes. The computed inputAttributes only contains non-prop attrs (plus id), so there’s no chance of forwarding autocomplete twice. Keeping the explicit

:autocomplete="autocomplete"

binding is both necessary and correct.

Likely an incorrect or invalid review comment.

@Sqrcz Sqrcz self-assigned this Aug 7, 2025
@Sqrcz Sqrcz added the 🔧 enhancement New feature or request label Aug 7, 2025
@Sqrcz
Copy link
Collaborator

Sqrcz commented Aug 7, 2025

Hey @ChrisWSchultz 👋

Thank you for your input... it looks very good and the description is 👌

I'm on holidays until Monday... if I find a moment to properly go through it... I will... but probably I'll take care of it somewhere next week.

Copy link

@xasanalixasanxabad-png xasanalixasanxabad-png left a comment

Choose a reason for hiding this comment

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

Forex

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.

Thanks for the great contribution! This improves accessibility and input handling nicely.

Looking forward to more contributions from you ;)

Comment on lines +11 to +17
return props.label
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '') // Remove special characters
.replace(/\s+/g, '-') // Replace spaces with hyphens
.replace(/-+/g, '-') // Collapse multiple hyphens
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider enhancing the slug generation logic to handle edge cases with special or accented characters in future iterations. Currently, strings like ąśćźż result in empty outputs, which may leave elements without valid id attributes. Using a transliteration solution (such as any-ascii), or alternatively generating a random string fallback when the result is empty, could improve robustness and accessibility.

@Sqrcz Sqrcz merged commit 9d220c2 into themesberg:main Oct 1, 2025
4 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
3 participants