Skip to content

[table] Fix infinite loop in eachUniqueFullRow/Column for unbounded intervals#8134

Merged
ggdouglas merged 3 commits into
palantir:developfrom
adityasingh2400:fix/each-unique-full-row-unbounded-interval
Jun 3, 2026
Merged

[table] Fix infinite loop in eachUniqueFullRow/Column for unbounded intervals#8134
ggdouglas merged 3 commits into
palantir:developfrom
adityasingh2400:fix/each-unique-full-row-unbounded-interval

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Fixes #6383

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Regions.eachUniqueFullRow and Regions.eachUniqueFullColumn iterate from the interval start to its end with a counting for loop. When a full-row or full-column region has an unbounded end (for example rows: [1, Infinity]), the loop never terminates. As noted in #6383, such a region can be produced by shift-clicking a row header and then passed to the public API inside an onSelection handler, at which point the page hangs (or eventually throws RangeError: Invalid array length once an accumulating array overflows).

This change skips any full-row or full-column region whose interval end is not finite, so the iteration cannot run unbounded. Bounded regions in the same array continue to be enumerated as before. The maintainer's comment on the issue pointed at these exact loops and suggested the function should short circuit, which is what this does.

Reviewers should focus on:

Whether silently skipping an unbounded region is the preferred behavior versus clamping it to the table bounds. These iteration helpers do not receive numRows/numCols, so skipping is the least surprising option without changing the signatures. The internal callers in table.tsx (handleRowHeightChanged / handleColumnWidthChanged) write into bounded arrays, so they are unaffected in practice; the user-facing impact is in the public Regions API.

Verification: nx run @blueprintjs/table:compile, vitest run regions.test.ts (38 passing), and eslint on the changed files all pass. The added test "does not hang on unbounded intervals" fails without the fix and passes with it.

…terval

Regions.eachUniqueFullRow and Regions.eachUniqueFullColumn iterate from the
interval start to its end with a counting loop. When a full-row or full-column
region has an unbounded end (e.g. rows of [1, Infinity], which can result from
shift-clicking a row or column header and is then passed to the public API in
an onSelection handler), the loop never terminates and the tab hangs or throws
once the accumulator array overflows.

Skip regions whose interval end is not finite so the iteration cannot run
unbounded. Bounded regions in the same array are still enumerated normally.

Fixes palantir#6383.
@palantirtech
Copy link
Copy Markdown
Member

Thanks for your interest in palantir/blueprint, @adityasingh2400! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented May 24, 2026

Generate changelog in packages/table/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[table] Fix infinite loop in eachUniqueFullRow/Column for unbounded intervals

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented May 27, 2026

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

🐛 Fixes

  • [table] Fix infinite loop in eachUniqueFullRow/Column for unbounded intervals (#8134)

fix:
description: "`Regions.eachUniqueFullRow` and `Regions.eachUniqueFullColumn` no longer hang on regions with an unbounded interval"
links:
- https://github.com/palantir/blueprint/pull/8134
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you remove this changelog entry? Per our contribution conventions, changelog entries aren't authored as part of the PR, they're generated separately. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed it. Thanks for the pointer, I did not realize changelog entries are generated separately rather than authored in the PR. Apologies for the extra file.

Copy link
Copy Markdown
Contributor

@ggdouglas ggdouglas left a comment

Choose a reason for hiding this comment

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

Verified locally: repros the RangeError on develop and returns instantly on this branch. LGTM, thanks!

@adityasingh2400
Copy link
Copy Markdown
Contributor Author

Thanks for verifying it locally and for the review, much appreciated.

@ggdouglas ggdouglas merged commit 595798d into palantir:develop Jun 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eachUniqueFullRow crashes with header row shift-click

3 participants