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): [input] fix input container 1px higher than input #2504

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Nov 8, 2024

…2490

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

close #2490

Summary by CodeRabbit

  • New Features
    • Updated font sizes for small and mini input elements to ensure visual consistency.
  • Style
    • Enhanced styling by setting explicit font sizes for improved coherence across input variations.

@gimmyhehe gimmyhehe added the bug Something isn't working label Nov 8, 2024
Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

The changes in this pull request involve updates to the index.less file, specifically for the small and mini input sizes. The font-size for both input classes has been set to a new variable, ensuring consistency across these sizes. Additionally, the @{input-prefix-cls}__inner selector has been modified to inherit the new font size. These adjustments aim to enhance the visual coherence of the input elements without altering the overall structure or logic of the styles.

Changes

File Change Summary
packages/theme/src/input/index.less Added font-size: var(--tv-Input-small-font-size); to &-small and &-mini classes. Updated @{input-prefix-cls}__inner to inherit the new font size.

Assessment against linked issues

Objective Addressed Explanation
Ensure consistent heights for input components in complex layouts (#2490)

Possibly related PRs

Suggested reviewers

  • zzcr

🐇 In the meadow, where the inputs play,
Font sizes change, brightening the day.
Small and mini, now all align,
A hop and a skip, everything's fine!
With styles so neat, we dance and we cheer,
Consistency's here, let’s spread the good cheer! 🥕✨


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.

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

@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 and nitpick comments (2)
packages/theme/src/input/index.less (2)

Line range hint 269-273: Consider using a distinct font size for mini variant.

Currently, both small and mini variants use var(--tv-Input-small-font-size). For better visual hierarchy, consider:

  1. Creating a separate variable like --tv-Input-mini-font-size
  2. Using a slightly smaller value for the mini variant
 &-mini {
   .input-size(var(--tv-Input-mini-height));
-  font-size: var(--tv-Input-small-font-size);
+  font-size: var(--tv-Input-mini-font-size);
   .@{input-prefix-cls}__inner {
-    font-size: var(--tv-Input-small-font-size);
+    font-size: var(--tv-Input-mini-font-size);
   }

The 1px height difference is likely due to border calculation

The analysis reveals the root cause of the height misalignment:

  1. The input container has border: 1px solid var(--tv-Input-border-color)
  2. Both container and inner input use the same height variable
  3. While both elements use box-sizing: border-box, the inner input has border: 0

This means:

  • Container height = specified height (includes 1px border top + 1px border bottom)
  • Inner input height = specified height (no borders)

Recommendations:

  • Either subtract 2px from the container height to account for borders
  • Or add corresponding borders to the inner input
  • Or adjust the --tv-Input-small-height variable to account for the border difference

The font-size changes alone won't fix this structural box model issue.

🔗 Analysis chain

Line range hint 258-262: Verify if font-size changes fully address the height issue.

While adjusting the font size can affect height calculations, it's unclear if this alone resolves the 1px height difference between the input container and input. Consider:

  1. Explicitly verifying the computed heights after this change
  2. Checking if additional adjustments to height/line-height are needed

Let me try to find more specific information about the input sizing and height calculations.


Font-size changes alone may not fully address the height misalignment

Based on the codebase analysis, the height alignment between input container and input is controlled by multiple factors:

  1. The input container and inner input both use var(--tv-Input-height) for height and line-height
  2. The .input-size() mixin is applied with var(--tv-Input-small-height) for small inputs
  3. While font-size can affect text rendering height, the explicit height variables should be the primary control for component dimensions

The current changes only modify font-size without adjusting any height-related properties. Since both container and input already share the same height variable, the 1px difference might be caused by:

  • Border calculations
  • Box-sizing differences
  • Padding/margin inconsistencies

Let's verify the box model properties:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for height-related properties that might affect the container/input alignment
rg -l "height|line-height" --type less

Length of output: 141


Script:

#!/bin/bash
# Search for height-related properties in the input less file
rg "height|line-height" "packages/theme/src/input/index.less"

# Also search for the input-size mixin definition
ast-grep --pattern 'mixin input-size($_) {
  $$$
}'

Length of output: 670


Script:

#!/bin/bash
# Search for any CSS variable definitions related to input heights
rg "tv-Input.*height|tv-Input.*line-height" "packages/theme/src/input"

Length of output: 1258


Script:

#!/bin/bash
# Look for the small input class definition
rg "input.*small|small.*input" "packages/theme/src/input/index.less" -A 5 -B 5

Length of output: 367


Script:

#!/bin/bash
# Search for border, padding, margin, and box-sizing properties
rg "border|padding|margin|box-sizing" "packages/theme/src/input/index.less"

# Also check input-related variables
rg "tv-Input.*(border|padding|margin)" "packages/theme/src/input/vars.less"

Length of output: 2268

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8eb46c5 and 59acd92.

📒 Files selected for processing (1)
  • packages/theme/src/input/index.less (2 hunks)
🔇 Additional comments (1)
packages/theme/src/input/index.less (1)

Line range hint 258-273: Additional investigation needed for height alignment.

The current changes focus on font-size adjustments, which might indirectly affect height calculations. However, to fully address the 1px height difference:

  1. Consider investigating the computed box model (margins, paddings, borders) of both container and input
  2. You might need to adjust height-related properties directly
  3. Add regression tests to ensure consistent heights across different size variants
#!/bin/bash
# Search for height-related mixins that might need adjustment
ast-grep --pattern 'mixin input-size($_) {
  $$$
}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants