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

Fix Input Clearable #1525

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix Input Clearable #1525

wants to merge 2 commits into from

Conversation

mikerowe81
Copy link
Contributor

@mikerowe81 mikerowe81 commented Feb 10, 2025

Closes #

📑 Description

Input component with clearable prop needs to use the relative wrapper in order for the clear (X) button to position correctly. Also modified the end class for better alignment.

Status

  • Not Completed
  • Completed

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • I have checked the page with https://validator.unl.edu/
  • All the tests have passed
  • My pull request is based on the latest commit (not the npm version).

ℹ Additional Information

Summary by CodeRabbit

  • New Features
    • Enhanced clearable input behavior for a more intuitive experience: When clearable, the input field now provides a distinct visual indication and an updated control layout.
    • Optimized positioning of the clear control improves accessibility and ensures the control appears precisely when needed.

Copy link

vercel bot commented Feb 10, 2025

Someone is attempting to deploy a commit to the Themesberg Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

Walkthrough

The changes update the Input.svelte component by modifying its subcomponents' rendering logic. The Wrapper now considers the clearable property when determining its display, in addition to checking for left or right slots. Additionally, the CloseButton component's CSS class has been revised from end-6 to end-1, altering its position within the layout. No exported or public entities were modified.

Changes

File(s) Summary
src/lib/forms/Input.svelte Updated Wrapper to check the clearable property for visibility; changed CloseButton class from end-6 to end-1

Sequence Diagram(s)

sequenceDiagram
    participant Input as Input.svelte
    participant Wrapper as Wrapper Component
    participant Button as CloseButton Component

    Input->>Wrapper: Determine show state (check left/right slots & clearable prop)
    Wrapper-->>Input: Return display state
    Input->>Button: Render CloseButton with updated class (end-1)
    Button-->>Input: Rendered button positioned closer to right edge
Loading

Possibly related PRs

Poem

I’m a bunny, hopping with glee,
In code-fields fresh as dew,
The wrapper now shines when clearable is true,
The close button leaps closer, brand new,
Celebrating clean code, through and through!
🐰🎉


📜 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 c53d5b9 and e788538.

📒 Files selected for processing (1)
  • src/lib/forms/Input.svelte (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Playwright and Lint
🔇 Additional comments (2)
src/lib/forms/Input.svelte (2)

85-85: LGTM! Good improvement to wrapper visibility logic.

Adding clearable to the wrapper's show condition ensures proper positioning context for the clearable button, which aligns well with the PR's objective of fixing the input clearable positioning.


100-100: Verify the new close button positioning.

The close button position has been moved significantly closer to the right edge (from 1.5rem to 0.25rem). While this fixes the positioning issue, please verify that this new position:

  1. Aligns with the design system's spacing standards
  2. Maintains sufficient spacing from the input's right border
  3. Doesn't overlap with any right slot content when both are present
❌ Verification inconclusive

🌐 Web query:

What are the standard button positioning practices in Flowbite design system for clearable inputs?

💡 Result:

Flowbite's design system positions clearable input buttons and related action buttons using these practices:

Clearable Input Positioning

  • Clear buttons appear as right-aligned icons inside the input field[1][4]
  • Implemented through dedicated clearable prop that adds an X mark on hover[4]
  • Automatically appears after text entry without manual positioning[1][4]
<Input clearable value="Clearable input" />  <!-- Auto-positioned right icon -->

Form Button Alignment

For forms containing clearable inputs:

  • Primary actions (Submit/Search) use right alignment[3][10]
  • Secondary actions appear left-aligned when needed[3]
  • Button groups use flex containers for spacing[1][4]
<ButtonGroup class="w-full">
  <InputAddon>@</InputAddon>
  <Input placeholder="Search" />
  <Button color="primary" slot="right">  <!-- Primary action right-aligned -->
    <SearchOutline />
  </Button>
</ButtonGroup>

Search Input Pattern

Search interfaces combine both patterns:

  1. Clear button inside input (right)
  2. Search button immediately adjacent (far right)[1][10]
<Input placeholder="Search" clearable>
  <SearchOutline slot="left" />
  <Button slot="right" type="submit">Search</Button>
</Input>

This follows Flowbite's principle of keeping interactive elements visually connected to their associated inputs while maintaining consistent right-side alignment for primary actions[3][7][10].

Citations:


Verify the close button’s spacing relative to the input.

Based on Flowbite’s guidelines, clearable input icons should be right-aligned inside the input field. However, Flowbite’s documentation doesn’t prescribe an explicit spacing value (like 0.25rem or 1.5rem) but instead relies on the input’s internal padding and the auto-positioning provided by the clearable prop. With the change from end-6 (1.5rem) to end-1 (0.25rem):

  • Ensure that the input element’s right padding compensates for the closer placement so that the close button isn’t too near the border.
  • Double-check that the revised spacing does not cause the button to overlap or conflict with any right slot content when both are present.
  • Confirm that the visual design remains consistent with Flowbite standards and overall design system expectations (e.g., clear and accessible interaction areas).

Please review these points in your design prototypes or during a manual visual QA session to ensure alignment with the design system.


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.

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