Skip to content

Conversation

@uma-uc
Copy link

@uma-uc uma-uc commented Jul 16, 2025

Description

This PR [adds/removes/fixes/replaces] the [feature/bug/etc].

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ examples
  • πŸ™… no documentation needed

Summary by CodeRabbit

  • New Features

    • Added support for two new responsive breakpoints (xs and xxs) across grid layouts, enabling finer control for smaller screen sizes.
    • Introduced a new demo component showcasing bounded dragging within the grid.
  • Bug Fixes

    • Improved drag boundary calculations for grid items to ensure proper clamping without unintended padding offsets.
  • Tests

    • Added tests to verify correct drag behavior when grid items are bounded.
    • Enhanced test utilities for simulating drag-and-drop interactions.
  • Chores

    • Updated .gitignore to ignore the dist directory.
    • Adjusted test setup to use legacy React DOM rendering for compatibility.

@coderabbitai
Copy link

coderabbitai bot commented Jul 16, 2025

Walkthrough

The changes introduce two new responsive breakpoints, "xs" and "xxs", across the grid layout system, updating default properties and type definitions to support finer control on smaller screens. The grid compaction algorithm is optimized by passing a bottom boundary parameter. Additional tests and a demo component are added to verify bounded dragging behavior. Minor adjustments include a .gitignore update and a test utility refactor.

Changes

Files/Groups Change Summary
.gitignore Added dist to ignored paths.
lib/GridItem.jsx Removed containerPadding from position clamping logic for draggable items.
lib/ResponsiveReactGridLayout.jsx, lib/responsiveUtils.js Added "xs" and "xxs" breakpoints to default props and type aliases.
lib/utils.js Optimized compact and compactItem functions by introducing a bottom boundary parameter to avoid repeated calculations.
test/examples/00-showcase.jsx, test/examples/06-dynamic-add-remove.jsx, test/examples/08-localstorage-responsive.jsx, test/examples/14-toolbox.jsx, test/examples/15-drag-from-outside.jsx Extended cols property to include "xs" and "xxs" breakpoints.
test/examples/17-responsive-bootstrap-style.jsx Added "xs" and "xxs" to cols and widths properties for finer responsive control.
test/examples/test_demo.jsx Introduced new IsBounded component for testing bounded drag behavior.
test/spec/lifecycle-test.js Added helpers and a new test verifying correct transform output when isBounded is true.
test/test-hook.jsx Switched from createRoot to legacy ReactDOM.render for mounting components.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant IsBounded (Component)
  participant ReactGridLayout
  participant DOM

  User->>IsBounded: Mount component
  IsBounded->>ReactGridLayout: Render with isBounded=true
  User->>DOM: Initiate drag on GridItem
  DOM->>ReactGridLayout: Drag events
  ReactGridLayout->>DOM: Apply transform (bounded)
  ReactGridLayout->>IsBounded: Call onDragStop callback
Loading

Poem

πŸ‡
New breakpoints hop in, "xs" and "xxs"
For grids that flex on screens both wide and less.
Compaction is smarter, the tests are more sound,
Bounded drags keep items well-bound.
With every tweak, the layout grows neatβ€”
The code garden’s tidy, and rabbits can eat!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

πŸ”§ ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

lib/GridItem.jsx

(node:24478) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

lib/responsiveUtils.js

(node:24480) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

lib/ResponsiveReactGridLayout.jsx

(node:24479) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

  • 10 others
✨ Finishing Touches
  • πŸ“ Generate Docstrings

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
πŸͺ§ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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

πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 40a1676 and 5663aec.

β›” Files ignored due to path filters (2)
  • dist/react-grid-layout.min.js is excluded by !**/dist/**, !**/*.min.js
  • dist/react-grid-layout.min.js.map is excluded by !**/dist/**, !**/*.map, !**/*.min.js.map
πŸ“’ Files selected for processing (14)
  • .gitignore (1 hunks)
  • lib/GridItem.jsx (1 hunks)
  • lib/ResponsiveReactGridLayout.jsx (1 hunks)
  • lib/responsiveUtils.js (1 hunks)
  • lib/utils.js (3 hunks)
  • test/examples/00-showcase.jsx (1 hunks)
  • test/examples/06-dynamic-add-remove.jsx (1 hunks)
  • test/examples/08-localstorage-responsive.jsx (2 hunks)
  • test/examples/14-toolbox.jsx (1 hunks)
  • test/examples/15-drag-from-outside.jsx (1 hunks)
  • test/examples/17-responsive-bootstrap-style.jsx (2 hunks)
  • test/examples/test_demo.jsx (1 hunks)
  • test/spec/lifecycle-test.js (2 hunks)
  • test/test-hook.jsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/examples/test_demo.jsx (1)
index.d.ts (1)
  • WidthProvider (167-167)
lib/GridItem.jsx (1)
lib/calculateUtils.js (9)
  • calcGridItemWHPx (25-35)
  • h (148-148)
  • clamp (163-169)
  • calcGridColWidth (14-19)
  • positionParams (15-15)
  • positionParams (55-55)
  • positionParams (108-108)
  • positionParams (141-141)
  • w (147-147)
test/spec/lifecycle-test.js (1)
test/examples/test_demo.jsx (2)
  • IsBounded (7-25)
  • IsBounded (7-25)
πŸͺ› Biome (1.9.4)
lib/utils.js

[error] 243-243: Shouldn't redeclare 'b'. Consider to delete it or rename it.

'b' is defined here:

(lint/suspicious/noRedeclare)


[error] 325-325: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 325-325: expected , but instead found ?

Remove ?

(parse)


[error] 326-326: Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax.

TypeScript only syntax

(parse)


[error] 327-327: return types can only be used in TypeScript files

(parse)


[error] 328-329: This code is unreachable

(lint/correctness/noUnreachable)


[error] 330-330: This code is unreachable

(lint/correctness/noUnreachable)

πŸ”‡ Additional comments (20)
lib/responsiveUtils.js (1)

8-8: LGTM! Proper type extension for new breakpoints.

The addition of "xs" and "xxs" breakpoints to the DefaultBreakpoints type alias correctly extends the responsive system to support finer-grained screen size control.

test/test-hook.jsx (1)

2-2: No createRoot usage foundβ€”regression claim is invalid.

The file test/test-hook.jsx imports from "react-dom" and exclusively uses ReactDOM.render; there’s no react-dom/client or createRoot anywhere in the codebase. You can safely ignore the original regression comment.

Likely an incorrect or invalid review comment.

test/examples/08-localstorage-responsive.jsx (2)

22-22: LGTM! Consistent breakpoint extension in defaultProps.

The addition of xs: 4, xxs: 2 to the default column configuration properly extends responsive support for smaller screen sizes, following a logical progression from the existing breakpoints.


42-42: LGTM! Consistent breakpoint extension in render props.

The breakpoint configuration matches the defaultProps, ensuring consistency between the static definition and runtime usage.

lib/GridItem.jsx (1)

513-521: Verify removal of containerPadding in drag boundary calculations

The onDrag logic now clamps top and left without accounting for containerPadding, altering how items snap to the container edges. There are currently no tests covering bounded dragging (isBounded: true), so please manually confirm:

  • Grids with non-zero containerPadding still prevent items from spilling over padded edges
  • The new xs and xxs breakpoints (where containerPadding defaults to null) behave as expected
  • Visual consistency matches previous versions when containerPadding is provided
test/examples/14-toolbox.jsx (1)

42-42: LGTM! Consistent breakpoint extension for toolbox example.

The addition of xs: 4, xxs: 2 to the column configuration maintains consistency with other example components and properly extends responsive support for the toolbox layout.

test/examples/06-dynamic-add-remove.jsx (1)

12-12: LGTM! Responsive breakpoint addition follows best practices.

The addition of xs: 4, xxs: 2 breakpoints creates a logical progression of decreasing column counts for smaller screen sizes, enhancing the responsive behavior of the grid layout.

test/examples/00-showcase.jsx (1)

31-31: LGTM! Consistent breakpoint values across examples.

The breakpoint values match other example files, maintaining consistency in the responsive grid system across the library.

test/examples/15-drag-from-outside.jsx (1)

11-11: LGTM! Maintains consistency across example suite.

The breakpoint addition is consistent with other examples and follows the established responsive design pattern.

test/examples/test_demo.jsx (1)

1-25: LGTM! Well-structured test component for bounded dragging.

The component follows established patterns:

  • Proper use of WidthProvider HOC
  • Clean layout definition for testing purposes
  • Correct prop passing for onDragStop callback
  • Appropriate use of isBounded={true} for testing drag constraints

The implementation is focused and suitable for its testing purpose.

test/examples/17-responsive-bootstrap-style.jsx (2)

16-16: LGTM! Bootstrap-style 12-column grid pattern maintained.

Using 12 columns for xs and xxs breakpoints is appropriate for a bootstrap-style layout, maintaining consistency with bootstrap's responsive grid system.


39-39: LGTM! Width configuration properly synchronized with column counts.

The widths object correctly maps the new breakpoints to 12, ensuring consistency between the cols and widths configurations in the bootstrap-style layout.

lib/ResponsiveReactGridLayout.jsx (1)

164-166: LGTM! New responsive breakpoints enhance small screen support.

The addition of xs (480px) and xxs (0px) breakpoints with appropriate column counts (4 and 2 respectively) provides better granular control for smaller screens. The configuration is consistent with the existing pattern.

test/spec/lifecycle-test.js (3)

19-42: LGTM! Well-implemented mouse event helper function.

The mouseMove function correctly creates and dispatches a synthetic mousemove event with proper initialization parameters. This is a good utility for testing drag behavior.


43-50: LGTM! Clean drag simulation helper function.

The simulateMovementFromTo function provides a clean abstraction for simulating complete drag sequences with mouseDown, mouseMove, and mouseUp events. Good reusable test utility.


466-480: LGTM! Test correctly verifies bounded drag behavior.

The test properly mounts the IsBounded component, simulates a drag operation, and verifies that the transform output matches the expected "translate(10px,0px)" format. This effectively tests the bounded dragging functionality.

lib/utils.js (4)

242-243: LGTM! Good optimization to track bottom position.

Tracking the bottom position of static items upfront and passing it to compactItem avoids repeated bottom calculations, improving performance during layout compaction.


254-255: LGTM! Efficient bottom position tracking.

The bottom position is correctly updated after each item compaction and passed to subsequent compactItem calls. This maintains accuracy while avoiding redundant calculations.


325-327: Ignore static analysis false positives - Flow types are correct.

The static analysis tool is incorrectly flagging Flow type annotations as TypeScript syntax. The function signature correctly adds the b: number parameter for the bottom position optimization. The "unreachable code" warnings are also false positives caused by the linter's confusion with Flow syntax.


334-334: LGTM! Efficient use of pre-calculated bottom position.

Using the passed b parameter instead of recalculating bottom(compareWith) improves performance while maintaining the same logical behavior.

Comment on lines +3 to 6
dist
dist/*
!dist/react-grid-layout.min*
!dist/*.html
Copy link

Choose a reason for hiding this comment

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

πŸ’‘ Verification agent

❓ Verification inconclusive

dist entry shadows the later negate rules – minified bundles & HTML will now be ignored

Adding the bare dist pattern ignores the directory itself, so Git stops traversing its contents.
The subsequent negations (!dist/react-grid-layout.min*, !dist/*.html) therefore no longer take effect, meaning the artefacts you explicitly wanted to keep tracked will be excluded from commits and npm publishes.

Remove the new line or restructure the rules as follows:

-# Ignore entire dist directory (breaks negate rules below)
-dist
+# Keep specific build artefacts, ignore everything else inside dist
+dist/*
+!dist/react-grid-layout.min*
+!dist/*.html

Failing to fix this will drop your distributable assets from the repo and packaged tarball.
Please verify npm pack output after the change.


Restructure .gitignore to preserve specific dist artefacts

The bare dist entry prevents Git from descending into that directory, so your negations never take effect. Remove it and ignore everything inside dist/ first, then re-include the files you need.

β€’ File: .gitignore
β€’ Lines: 3–6

- dist
+# Keep only our minified bundle & HTML, ignore all other files under dist
+ dist/*
  !dist/react-grid-layout.min*
  !dist/*.html

After updating, confirm your changes with git check-ignore -v dist/react-grid-layout.min.js or by running npm pack to ensure the artefacts are included.

Committable suggestion skipped: line range outside the PR's diff.

πŸ€– Prompt for AI Agents
In the .gitignore file at lines 3 to 6, remove the bare "dist" entry because it
prevents Git from checking inside the dist directory, making the negation rules
ineffective. Instead, ignore all files inside dist/ with "dist/*" first, then
explicitly re-include the needed files like "dist/react-grid-layout.min*" and
"dist/*.html" using negation patterns. After making these changes, verify with
"git check-ignore -v dist/react-grid-layout.min.js" or by running "npm pack" to
confirm the correct files are included.

Comment on lines +47 to +50
ReactDOM.render(
React.createElement(ListeningLayout, gridProps),
contentDiv
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update rendering logic to use modern React 18 API.

Correspondingly, the rendering logic should use the modern createRoot API instead of the deprecated ReactDOM.render.

-    ReactDOM.render(
-      React.createElement(ListeningLayout, gridProps),
-      contentDiv
-    );
+    const root = createRoot(contentDiv);
+    root.render(React.createElement(ListeningLayout, gridProps));

Committable suggestion skipped: line range outside the PR's diff.

πŸ€– Prompt for AI Agents
In test/test-hook.jsx around lines 47 to 50, replace the deprecated
ReactDOM.render call with the modern React 18 createRoot API. Import createRoot
from 'react-dom/client', create a root using createRoot(contentDiv), and then
call root.render with the React element. This updates the rendering logic to
conform to React 18 standards.

@mann1996 mann1996 merged commit 0f4d1d8 into master Jul 21, 2025
1 check passed
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.

3 participants