Skip to content

chore: add max height for textarea#39542

Merged
jsartisan merged 2 commits intoreleasefrom
chore/max-height-for-textarea
Mar 4, 2025
Merged

chore: add max height for textarea#39542
jsartisan merged 2 commits intoreleasefrom
chore/max-height-for-textarea

Conversation

@jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Mar 4, 2025

/ok-to-test tags="@tag.Anvil"

CleanShot.2025-03-04.at.13.00.56.mp4

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Updated textarea inputs with a maximum height setting to improve layout consistency.
    • The TextArea component now accepts a new property for specifying its maximum number of rows.
  • Documentation

    • Added a Storybook example demonstrating the new max height functionality for the TextArea component.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13652776635
Commit: fc4fd3f
Cypress dashboard.
Tags: @tag.Anvil
Spec:


Tue, 04 Mar 2025 11:57:15 UTC

@jsartisan jsartisan requested a review from a team as a code owner March 4, 2025 07:31
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

Walkthrough

This pull request introduces enhancements to the textarea input elements by adding a maxRows property to the TextArea component, which is utilized to set a CSS variable for maximum height. Corresponding CSS properties are added to the stylesheet to enforce height constraints. Additionally, a new Storybook story is created to demonstrate the functionality of the maxRows property.

Changes

File(s) Change Summary
app/.../Input/src/styles.module.css Added max-height: var(--max-height);, padding-block: 0;, and margin-block: var(--inner-spacing-1); to the .input:is(textarea) selector.
app/.../TextArea/src/{TextArea.tsx, types.ts, stories/*.tsx} Introduced a maxRows prop to the TextArea component, updated TypeScript type declarations, and added a new Storybook story named MaxHeight.

Sequence Diagram(s)

sequenceDiagram
    participant S as Storybook
    participant T as TextArea Component
    participant B as Browser
    S->>T: Render TextArea with maxRows prop (e.g., 8)
    T->>T: Set CSS variable (--max-height) based on maxRows
    T->>B: Renders component with applied CSS rule for textarea
Loading

Possibly related PRs

Suggested labels

Property Pane, Widgets Product, UI Building Product, Widget Property, IDE Product

Suggested reviewers

  • KelvinOm

Poem

In the code realm, a tweak takes flight,
A new max-height brings order to sight.
TextArea dons a prop so neat,
Storybook shines with a demo treat.
Cheers to changes crisp and light!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b332566 and fc4fd3f.

📒 Files selected for processing (4)
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx

[error] 115-115: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (5)
app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (5)

33-33: Good addition of the maxRows property.

This property addition aligns well with the PR objective to limit textarea height.


48-48: Variable naming correction is good.

Fixed the state setter function name to maintain consistency.


74-74: Properly using the renamed state setter.

The corrected setter function is used here appropriately.


115-117: Remove redundant Boolean() call.

The Boolean conversion is unnecessary as the value will already be coerced to a boolean in this context.

- "--max-height": Boolean(maxRows)
-   ? `calc(${maxRows} * var(--body-line-height))`
-   : "none",
+ "--max-height": maxRows
+   ? `calc(${maxRows} * var(--body-line-height))`
+   : "none",
🧰 Tools
🪛 Biome (1.9.4)

[error] 115-115: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)


115-117: Good implementation of max-height calculation.

The calculation using CSS calc() and variable multiplier provides a clean way to limit height based on the number of rows. This effectively implements the main PR objective.

🧰 Tools
🪛 Biome (1.9.4)

[error] 115-115: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

✨ Finishing Touches
  • 📝 Generate Docstrings

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

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Mar 4, 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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a5a654 and b332566.

📒 Files selected for processing (4)
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx

[error] 117-117: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (5)
app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx (1)

75-80: Good addition of the MaxHeight story to demonstrate the new prop.

This story effectively showcases the maxHeight feature, allowing users to see how the TextArea behaves with a max height constraint. Consider adding a description to clarify what this story demonstrates.

app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1)

14-14: Appropriate type definition for maxHeight prop.

The optional numeric type is suitable for this property and matches the implementation in the component.

app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (2)

54-54: CSS implementation correctly adds max-height constraint.

This CSS property works well with the custom variable to apply the maximum height to textarea elements.


17-19: Verify if overflow property should be removed.

There's a comment on line 17 suggesting to "Delete overflow: hidden; when the max height is added", but the property still exists on line 18. Please verify if this comment is outdated or if the overflow property should be removed now that max-height has been implemented.

app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (1)

33-33: Good addition of maxHeight prop extraction.

The maxHeight prop is properly extracted from the props object.

"--input-height": Boolean(textFieldHeight)
? `${textFieldHeight}px`
: "auto",
"--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove redundant Boolean() call.

The Boolean() call is unnecessary since the ternary operator will already coerce the value to a boolean.

-    "--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
+    "--max-height": maxHeight ? `${maxHeight}px` : "none",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
"--max-height": maxHeight ? `${maxHeight}px` : "none",
🧰 Tools
🪛 Biome (1.9.4)

[error] 117-117: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a5a654 and b332566.

📒 Files selected for processing (4)
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx

[error] 117-117: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (4)
app/client/packages/design-system/widgets/src/components/TextArea/stories/TextArea.stories.tsx (1)

76-80: Appropriate story added for maxHeight demonstration.

The story correctly showcases the maxHeight property with a value of 100px, which follows the same pattern as other stories.

app/client/packages/design-system/widgets/src/components/TextArea/src/types.ts (1)

14-14: Type definition correctly added.

The maxHeight property is properly typed as an optional number parameter, which aligns with its usage.

app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (1)

54-54: CSS property appropriately implemented.

The max-height CSS property effectively leverages the custom variable, allowing dynamic control through props.

app/client/packages/design-system/widgets/src/components/TextArea/src/TextArea.tsx (1)

33-33: Prop correctly destructured from component props.

The maxHeight property is appropriately extracted from props for use in the component.

"--input-height": Boolean(textFieldHeight)
? `${textFieldHeight}px`
: "auto",
"--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove redundant Boolean call.

The Boolean conversion is unnecessary as the value will already be coerced to a boolean in this context.

- "--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
+ "--max-height": maxHeight ? `${maxHeight}px` : "none",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"--max-height": Boolean(maxHeight) ? `${maxHeight}px` : "none",
"--max-height": maxHeight ? `${maxHeight}px` : "none",
🧰 Tools
🪛 Biome (1.9.4)

[error] 117-117: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

@jsartisan jsartisan requested a review from KelvinOm March 4, 2025 10:14
@jsartisan jsartisan added the ok-to-test Required label for CI label Mar 4, 2025
align-items: flex-start;
resize: none;
font-family: inherit;
max-height: var(--max-height);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we use maxRows instead of the max-height? So let's say we have maxRows={5}, then we can calculate max-height like this: typography.body.lineHeight*maxRows.

cc @ichik

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it would make a lot of sense to use rows instead of raw pixels here.

@jsartisan jsartisan merged commit dce52df into release Mar 4, 2025
52 checks passed
@jsartisan jsartisan deleted the chore/max-height-for-textarea branch March 4, 2025 12:12
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
/ok-to-test tags="@tag.Anvil"


https://github.com/user-attachments/assets/b189bdb2-2391-4cd8-8867-7c233aba0059



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Updated textarea inputs with a maximum height setting to improve
layout consistency.
- The TextArea component now accepts a new property for specifying its
maximum number of rows.

- **Documentation**
- Added a Storybook example demonstrating the new max height
functionality for the TextArea component.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13652776635>
> Commit: fc4fd3f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13652776635&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Tue, 04 Mar 2025 11:57:15 UTC
<!-- end of auto-generated comment: Cypress test results  -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants