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

feat(input): add outside-top prop #3660

Conversation

abhinav700
Copy link
Contributor

@abhinav700 abhinav700 commented Aug 16, 2024

Closes #3058

📝 Description

⛳️ Current behavior (updates)

In old behaviour, the label was presented inside the input component if placholder === "" even if labelPlacement === "outside"

🚀 New behavior

Adding outside-top prop which dispalys the label outside the input component regardless of whether the placeholder is there or not.

image

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new label positioning option, "outside-top," for improved visibility and accessibility in the input component.
    • Enhanced layout options for the Input component with updated styling configurations.
  • Documentation

    • Updated component stories to showcase the new "outside-top" functionality.
    • Extended label placement options in documentation to include "outside-top."
    • Revised documentation to reflect changes in the labelPlacement property.

Copy link

changeset-bot bot commented Aug 16, 2024

🦋 Changeset detected

Latest commit: c7246b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@nextui-org/input Patch
@nextui-org/theme Patch
@nextui-org/autocomplete Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Aug 16, 2024

@abhinav700 is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (5)
  • main
  • canary
  • fix/.*
  • chore/.*
  • feat/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update enhances the Input component by introducing a new outside-top prop, allowing improved label positioning outside the input field. This change resolves an existing issue and increases design flexibility. Additionally, the styling of the component has been refined to accommodate this feature while enhancing usability through updated layout properties and conditional rendering logic.

Changes

Files Change Summary
.changeset/little-crabs-destroy.md, packages/components/input/src/input.tsx, packages/components/input/src/use-input.ts Added outside-top prop to the Input component, modifying layout handling, conditional rendering, and story options. Enhanced label placement logic in useInput.
packages/core/theme/src/components/input.ts Introduced new styling configuration for the outside-top layout, enhancing flexibility in rendering.
apps/docs/content/components/input/label-placements.ts, apps/docs/content/docs/components/input.mdx Updated documentation to include the new outside-top option for labelPlacement.
packages/components/input/stories/input.stories.tsx Updated stories to showcase the new outside-top option in the Input component.

Assessment against linked issues

Objective Addressed Explanation
Should allow label placement outside without needing a placeholder (3058)
Should improve usability of label placement options

Possibly related PRs

Suggested labels

👀 Status: In Review

Suggested reviewers

  • jrgarciadev

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

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

Outside diff range, codebase verification and nitpick comments (1)
packages/components/input/src/input.tsx (1)

20-20: Add documentation for the isOutsideTop prop.

The isOutsideTop prop is used to control label positioning in the Input component but lacks documentation. Please add comments or documentation to clarify its purpose and usage.

  • File: packages/components/input/src/input.tsx
  • File: packages/components/input/src/use-input.ts
Analysis chain

New prop isOutsideTop added.

The isOutsideTop prop is introduced to control the label positioning. Ensure this prop is documented and used consistently.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage and documentation of `isOutsideTop` prop.

# Test: Search for documentation or comments related to `isOutsideTop`.
rg --type md --type js --type ts --type tsx 'isOutsideTop'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify usage and documentation of `isOutsideTop` prop.

# Test: Search for documentation or comments related to `isOutsideTop`.
rg --type markdown --type javascript --type typescript --type tsx 'isOutsideTop'

Length of output: 115


Script:

#!/bin/bash
# Description: Verify usage and documentation of `isOutsideTop` prop.

# Test: Search for documentation or comments related to `isOutsideTop` across all files.
rg 'isOutsideTop'

Length of output: 444

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1973864 and 0dc983c.

Files selected for processing (5)
  • .changeset/little-crabs-destroy.md (1 hunks)
  • packages/components/input/src/input.tsx (6 hunks)
  • packages/components/input/src/use-input.ts (2 hunks)
  • packages/components/input/stories/input.stories.tsx (3 hunks)
  • packages/core/theme/src/components/input.ts (1 hunks)
Additional comments not posted (11)
.changeset/little-crabs-destroy.md (1)

1-6: Changeset is well-written and accurate.

The changeset correctly describes the addition of the outside-top prop and its purpose, along with the affected packages.

packages/components/input/src/input.tsx (3)

85-87: Conditional rendering logic updated.

The logic now considers isOutsideTop for label rendering. This enhances flexibility but ensure it doesn't introduce regressions.


52-57: Styling changes for error messages and descriptions.

The background color for error messages and descriptions has been updated. Ensure these changes align with the design guidelines.


120-120: Conditional label rendering with isOutsideTop.

The label is conditionally rendered based on isOutsideLeft or isOutsideTop. Ensure all scenarios are covered in tests.

packages/components/input/src/use-input.ts (3)

264-264: New variable isOutsideTop introduced.

The isOutsideTop variable is used to manage label positioning. Ensure this is consistently applied across the component.


268-279: Refined logic for isLabelOutside.

The logic for isLabelOutside has been refined to incorporate outside-top. Ensure this logic aligns with the intended behavior.


253-256: Enhanced label positioning logic with outside-top.

The logic for determining label placement now includes outside-top. Ensure this logic is thoroughly tested.

Verification successful

Test coverage for outside-top label placement is present.

The outside-top label placement is covered in the input.stories.tsx file, indicating it is demonstrated and tested through story examples. Ensure these stories are reviewed for completeness in visual testing.

  • packages/components/input/stories/input.stories.tsx: Demonstrates outside-top label placement.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for enhanced label positioning logic.

# Test: Search for test cases covering `outside-top` label placement.
rg --type ts --type tsx 'outside-top'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify test coverage for enhanced label positioning logic.

# Test: Search for test cases covering `outside-top` label placement.
rg --type=ts --type=tsx 'outside-top'

Length of output: 65


Script:

#!/bin/bash
# Description: Verify test coverage for enhanced label positioning logic.

# Test: Search for test cases covering `outside-top` label placement across all files.
rg 'outside-top'

Length of output: 900

packages/components/input/stories/input.stories.tsx (3)

52-52: Addition of "outside-top" to labelPlacement options is correct.

The inclusion of "outside-top" in the options array aligns with the PR objective to enhance label positioning. This change is consistent with existing options.


181-181: Addition of "outside-top" label placement in the story is appropriate.

The new Input component with labelPlacement="outside-top" ensures that the new feature is demonstrated and testable in the story.


200-205: Inclusion of "outside-top" with placeholder is well-implemented.

Adding this Input component tests the outside-top label placement with a placeholder, ensuring comprehensive coverage.

packages/core/theme/src/components/input.ts (1)

173-178: "outside-top" layout configuration is well-structured.

The addition of outside-top in the labelPlacement variant introduces a new layout that is consistent with the design goals. The CSS classes are appropriately defined to achieve the desired positioning.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0dc983c and 8f07cc8.

Files selected for processing (2)
  • apps/docs/content/components/input/label-placements.ts (1 hunks)
  • apps/docs/content/docs/components/input.mdx (1 hunks)
Additional comments not posted (2)
apps/docs/content/components/input/label-placements.ts (1)

8-8: Addition of outside-top label placement is correct.

The new label placement option "outside-top" has been added correctly to the array. This enhances the flexibility of the Input component.

apps/docs/content/docs/components/input.mdx (1)

78-78: Documentation for outside-top label placement is accurate.

The documentation correctly includes the new outside-top option for labelPlacement, providing clear guidance on its usage.

@wingkwong wingkwong self-assigned this Aug 16, 2024
@wingkwong wingkwong changed the title [FIX 3058] : Adding outside-top prop to the input component. feat(input): add outside-top prop Aug 17, 2024
@wingkwong wingkwong added this to the v2.5.0 milestone Aug 17, 2024
.changeset/little-crabs-destroy.md Outdated Show resolved Hide resolved
packages/components/input/src/input.tsx Outdated Show resolved Hide resolved
packages/components/input/src/input.tsx Outdated Show resolved Hide resolved
packages/components/input/src/input.tsx Outdated Show resolved Hide resolved
packages/components/input/src/input.tsx Outdated Show resolved Hide resolved
packages/components/input/src/use-input.ts Outdated Show resolved Hide resolved
packages/components/input/src/use-input.ts Outdated Show resolved Hide resolved
@abhinav700 abhinav700 requested a review from wingkwong August 17, 2024 05:46
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8f07cc8 and 43715c0.

Files selected for processing (3)
  • .changeset/little-crabs-destroy.md (1 hunks)
  • packages/components/input/src/input.tsx (3 hunks)
  • packages/components/input/src/use-input.ts (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .changeset/little-crabs-destroy.md
  • packages/components/input/src/input.tsx
  • packages/components/input/src/use-input.ts

@user72356
Copy link

user72356 commented Aug 26, 2024

Can anyone merge this? @jrgarciadev @wingkwong please?

@wingkwong
Copy link
Member

Can anyone merge this? @jrgarciadev @wingkwong please?

This PR is scheduled for v2.5.0. We will review and merge after v2.4.7.

@wingkwong wingkwong changed the base branch from canary to beta/release-next November 22, 2024 13:29
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

🧹 Outside diff range and nitpick comments (2)
.changeset/little-crabs-destroy.md (1)

6-6: Enhance the changeset description for better changelog clarity

While the current description is concise, it would be helpful to include more details about the feature's purpose and impact.

Consider expanding the description like this:

-introduce `outside-top` prop to input (#3058)
+introduce `outside-top` prop to input allowing label placement outside regardless of placeholder (#3058)
packages/components/input/package.json (1)

Line range hint 3-3: Consider semantic versioning for feature addition

Given that this PR introduces a new feature (outside-top prop), consider whether a minor version bump (2.3.0) would be more appropriate than a patch version (2.2.5), following semantic versioning principles.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2d9031c and efeca94.

📒 Files selected for processing (2)
  • .changeset/little-crabs-destroy.md (1 hunks)
  • packages/components/input/package.json (2 hunks)
🔇 Additional comments (1)
packages/components/input/package.json (1)

39-39: Verify the minimum theme version requirement

The peer dependency update for @nextui-org/theme to >=2.2.12 appears to be related to the new label positioning feature. Let's verify this is the minimum version required.

✅ Verification successful

Theme dependency update is justified

The theme dependency update to >=2.2.12 is necessary as the codebase shows the new outside-top label positioning feature requires theme support, evidenced by:

  • The feature is implemented in the theme component (packages/core/theme/src/components/input.ts includes outside-top styling)
  • The input component relies on this theme implementation (packages/components/input/src/use-input.ts references isOutsideTop)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check when the theme changes for label positioning were introduced

# Search for label-related changes in the theme package
rg -p "label.*outside.*top" packages/components/theme/

Length of output: 123


Script:

#!/bin/bash
# Let's try a broader search for theme-related label positioning
# First, find all theme-related files
fd -e js -e ts -e tsx theme

# Then search for label positioning in theme files
rg -p "label.*position" 

# Also check for any recent changes or additions related to label positioning
rg -p "outside.*top"

Length of output: 6814

.changeset/little-crabs-destroy.md Show resolved Hide resolved
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

seems this is only useful for "without placeholder". for "with placeholder, basically this prop is same as outside. I'm wondering if this would confuse users or not. @ryo-manba what do you think?

image

.changeset/little-crabs-destroy.md Show resolved Hide resolved
@wingkwong
Copy link
Member

marking this PR as on hold until the docs structure revamp pr merged to beta branch.

@abhinav700
Copy link
Contributor Author

abhinav700 commented Nov 22, 2024

seems this is only useful for "without placeholder". for "with placeholder, basically this prop is same as outside. I'm wondering if this would confuse users or not. @ryo-manba what do you think?

to resolve this, I think we can replace outside with something like outside-conditional or outside-partial or outside-top-partial

@ryo-manba
Copy link
Member

@wingkwong
I certainly see your point, but I think this is fine since it matches the outside-left behavior.
It might also be helpful to add a note in the docs that both outside-left and outside-top always display labels outside, even without a placeholder.

@wingkwong wingkwong removed their assignment Nov 29, 2024
@wingkwong
Copy link
Member

It might also be helpful to add a note in the docs that both outside-left and outside-top always display labels outside, even without a placeholder.

@abhinav700 please pull the latest code and add this note. Then we'll have a final review. Thanks.

@abhinav700 abhinav700 force-pushed the fix-3058/adding_outside-top_prop branch from c8a6a0c to c6f2658 Compare November 29, 2024 16:04
@abhinav700 abhinav700 force-pushed the fix-3058/adding_outside-top_prop branch from c6f2658 to c7246b1 Compare November 29, 2024 16:07
@abhinav700
Copy link
Contributor Author

@wingkwong I have pulled the code and updated the docs

@jrgarciadev jrgarciadev deleted the branch heroui-inc:beta/release-next November 29, 2024 19:54
@abhinav700 abhinav700 deleted the fix-3058/adding_outside-top_prop branch February 1, 2025 04:53
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.

[BUG] - Input - Label with placement "outside" only presented when placeholder === " "
5 participants