Skip to content

fix: layout glitches on multiline environment variables when scrolling#7732

Merged
bijin-bruno merged 7 commits into
usebruno:mainfrom
shubh-bruno:fix/multiline-env
Apr 16, 2026
Merged

fix: layout glitches on multiline environment variables when scrolling#7732
bijin-bruno merged 7 commits into
usebruno:mainfrom
shubh-bruno:fix/multiline-env

Conversation

@shubh-bruno
Copy link
Copy Markdown
Collaborator

@shubh-bruno shubh-bruno commented Apr 10, 2026

Description

Adds dynamic height compute to reduce glitchy render on tables with multiline values.

JIRA

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Rows now automatically append when you edit the final environment variable, streamlining data entry.
  • Style

    • Table height changes animate smoothly for a cleaner resize experience.
  • Bug Fixes

    • Input placeholders now correctly reflect each field’s content.
    • Improved table virtualization and scrolling for more consistent rendering and performance.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

Walkthrough

This PR adds a height transition to the EnvironmentVariablesTable container and adjusts virtualized row handling: forwards row styles/props, computes table height from variable count, bounds overscan, removes fixed item height, tweaks placeholders, and appends a new empty row when editing the last row's value.

Changes

Cohort / File(s) Summary
Styling
packages/bruno-app/src/components/EnvironmentVariablesTable/StyledWrapper.js
Added transition: height 75ms cubic-bezier(0.4,0,0.2,1) to .table-container to animate height changes.
Virtualized table & form logic
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js
TableRow now forwards style and other props; data-testid uses item?.name. Initial tableHeight computed from (environment.variables.length + 1) * MIN_ROW_HEIGHT. Removed fixedItemHeight, set overscan={Math.min(30, filteredVariables.length)}. Placeholders adjusted to depend on each field's emptiness. Editing last row's value schedules appending a new empty variable via setTimeout.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant UI as EnvironmentVariablesTable
  participant Virtuoso as TableVirtuoso
  participant Formik as Formik

  User->>UI: type into value field (last row)
  UI->>Formik: onChange(newValue)
  Note right of UI: detect isLastRow
  UI->>Formik: setTimeout -> append empty variable at next index (uid, defaults)
  Formik->>Virtuoso: variables list updated
  Virtuoso->>UI: re-render rows (forwards style/props)
  UI->>UI: container height changes
  Note right of UI: CSS transition animates height (rgba(0,0,0,0.5))
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno

Poem

✨ A keystroke grows a brand new row,

Virtuoso hums while values flow,
Heights slide soft, a gentle shift,
Placeholders guide the tiny drift,
Small tweaks, a UI-friendly glow.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the PR's stated objective of fixing a scrolling glitch with multiline environment variables, and the changes confirm this fix through virtualized table optimization and dynamic height handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js (1)

22-33: ⚠️ Potential issue | 🟠 Major

Fix the TableRow shape: item is { variable, index }, not the raw variable.

TableVirtuoso passes each element from filteredVariables directly as the item prop. Since filteredVariables contains { variable, index } objects, accessing item.uid and item.name returns undefined. This collapses all row data-testid values to env-var-row-undefined, breaking test selectors. The memoization comparator then compares undefined === undefined for every row (always true), preventing necessary re-renders. Excluding style from the comparison also breaks Virtuoso's positioning logic.

Suggested fix
 const TableRow = React.memo(
   ({ children, item, style, ...rest }) => (
-    <tr key={item.uid} style={style} {...rest} data-testid={`env-var-row-${item?.name}`}>
+    <tr
+      style={style}
+      {...rest}
+      data-testid={`env-var-row-${item?.variable?.uid ?? item?.index}`}
+    >
       {children}
     </tr>
-  ),
-  (prevProps, nextProps) => {
-    const prevUid = prevProps?.item?.uid;
-    const nextUid = nextProps?.item?.uid;
-    return prevUid === nextUid && prevProps.children === nextProps.children;
-  }
+  )
 );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js` around
lines 22 - 33, TableRow currently treats item as the raw variable but
TableVirtuoso provides item as { variable, index }, causing uid/name to be
undefined and memoization to incorrectly block renders; update the render to
read const variable = item?.variable and use variable?.uid for the key and
variable?.name in data-testid, and update the memo comparator to compare
prevProps.item?.variable?.uid !== nextProps.item?.variable?.uid (or equality)
plus prevProps.children === nextProps.children AND prevProps.style ===
nextProps.style so style changes from Virtuoso still trigger re-renders.
🧹 Nitpick comments (1)
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js (1)

627-628: Please rewrite or remove this inline note.

The sentence is hard to parse and already stale: it mentions 0.1s, while the new height transition is 0.15s. If this is a real follow-up, capture the concrete layout constraint instead of leaving a half-formed note.

As per coding guidelines "Add in meaningful comments instead of obvious ones where complex code flow is explained properly."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js` around
lines 627 - 628, The inline dev note in the EnvironmentVariablesTable component
about button placement is stale and unclear—remove it or replace it with a
concise, actionable comment that documents the real layout constraint:
TableVirtuoso's height transition (0.15s) can cause buttons inside the virtuoso
container to reflow during mount, so either render action buttons outside the
TableVirtuoso virtualization container or use a stable positioning strategy
(e.g., position: sticky/fixed or a separate toolbar) to avoid transition-driven
layout shifts; update the comment to reference TableVirtuoso and the 0.15s
transition and include the chosen mitigation so future maintainers know why the
buttons are placed where they are.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 563-565: The placeholder logic in EnvironmentVariablesTable treats
falsy values like 0 and false as empty because it uses !variable.value; update
the placeholder expression to only consider null/undefined or blank strings as
empty. Specifically, replace the !variable.value check in the placeholder prop
for the variable.value field with an explicit check like variable.value ===
undefined || variable.value === null || (typeof variable.value === 'string' &&
variable.value.trim() === '') so numeric 0 and boolean false are preserved as
real values.

---

Outside diff comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 22-33: TableRow currently treats item as the raw variable but
TableVirtuoso provides item as { variable, index }, causing uid/name to be
undefined and memoization to incorrectly block renders; update the render to
read const variable = item?.variable and use variable?.uid for the key and
variable?.name in data-testid, and update the memo comparator to compare
prevProps.item?.variable?.uid !== nextProps.item?.variable?.uid (or equality)
plus prevProps.children === nextProps.children AND prevProps.style ===
nextProps.style so style changes from Virtuoso still trigger re-renders.

---

Nitpick comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 627-628: The inline dev note in the EnvironmentVariablesTable
component about button placement is stale and unclear—remove it or replace it
with a concise, actionable comment that documents the real layout constraint:
TableVirtuoso's height transition (0.15s) can cause buttons inside the virtuoso
container to reflow during mount, so either render action buttons outside the
TableVirtuoso virtualization container or use a stable positioning strategy
(e.g., position: sticky/fixed or a separate toolbar) to avoid transition-driven
layout shifts; update the comment to reference TableVirtuoso and the 0.15s
transition and include the chosen mitigation so future maintainers know why the
buttons are placed where they are.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5ba89434-5814-477e-9b21-ae763bdc0495

📥 Commits

Reviewing files that changed from the base of the PR and between cd06f28 and 50869d4.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/EnvironmentVariablesTable/StyledWrapper.js
  • packages/bruno-app/src/components/EnvironmentVariablesTable/index.js

@pull-request-size pull-request-size Bot added size/M and removed size/S labels Apr 16, 2026
Copy link
Copy Markdown
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)
packages/bruno-app/src/components/EnvironmentVariablesTable/index.js (1)

628-629: Consider making this comment actionable.

If this is a known issue to address later, consider adding a TODO: prefix or linking to a tracking issue so it doesn't get lost.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js` around
lines 628 - 629, Convert the informal note above the TableVirtuoso buttons into
an actionable TODO: add a "TODO:" prefix, briefly describe the exact problem
(buttons cause TableVirtuoso to render with a transition height 0.1s), and
include either a tracking issue ID or a short URL (or "TBD" if none) so it can
be found later; update the comment near where TableVirtuoso and the buttons are
referenced (search for TableVirtuoso and the buttons render block in
EnvironmentVariablesTable) and keep the comment concise and neutral for future
follow-up.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 575-587: The value onChange handler appends a new row when
isLastRow is true, but handleNameChange does the same, causing duplicate empty
rows if both setTimeouts run; update the logic around formik.setFieldValue in
the value change branch (and similarly in handleNameChange if applicable) to
first check the current last row in formik.values (e.g., inspect
formik.values[formik.values.length - 1]) and only append a new empty row (via
formik.setFieldValue with uuid()) if that last row is not already an empty
placeholder (name === '' && value === '' && !secret or enabled state), or
alternatively gate the append with a boolean flag (e.g., isAppendingEmptyRow)
stored in component state to prevent double-appends.

---

Nitpick comments:
In `@packages/bruno-app/src/components/EnvironmentVariablesTable/index.js`:
- Around line 628-629: Convert the informal note above the TableVirtuoso buttons
into an actionable TODO: add a "TODO:" prefix, briefly describe the exact
problem (buttons cause TableVirtuoso to render with a transition height 0.1s),
and include either a tracking issue ID or a short URL (or "TBD" if none) so it
can be found later; update the comment near where TableVirtuoso and the buttons
are referenced (search for TableVirtuoso and the buttons render block in
EnvironmentVariablesTable) and keep the comment concise and neutral for future
follow-up.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7db3aeb3-7ce0-47ff-8c3e-7f4109a5b85a

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1ba7e and 88792e0.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/EnvironmentVariablesTable/index.js

@sid-bruno sid-bruno changed the title fix: scrolling glitch in environment fix: layout glitches on multiline environment variables when scrolling Apr 16, 2026
@bijin-bruno bijin-bruno merged commit c6281d3 into usebruno:main Apr 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants