Fix Math.max returning -Infinity when columnIndices is empty array#7728
Open
Nepomuk5665 wants to merge 2 commits intopalantir:developfrom
Open
Fix Math.max returning -Infinity when columnIndices is empty array#7728Nepomuk5665 wants to merge 2 commits intopalantir:developfrom
Nepomuk5665 wants to merge 2 commits intopalantir:developfrom
Conversation
…sByTallestCell When resizeRowsByTallestCell is called with an empty array for columnIndices, Math.max(...[]) returns -Infinity, causing all rows to have -Infinity height. This fix adds a length check to only compute the max when there are columns to process, otherwise the default value of 0 is used, which is the expected behavior matching the undefined columnIndices case where no columns are in view.
Member
|
Thanks for your interest in palantir/blueprint, @Nepomuk5665! 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. |
Generate changelog in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug in
resizeRowsByTallestCellwhere passing an empty array[]for thecolumnIndicesparameter causes all rows to be resized to-Infinityheight.Problem
When
resizeRowsByTallestCellis called withcolumnIndices = []:columnIndicesArraybecomes[]tallestByColumnsbecomes[](empty after map)Math.max(...[])returns-InfinityThis causes all rows to have
-Infinityheight, which is incorrect behavior.Solution
Add a length check before calling
Math.max(). WhencolumnIndicesArrayis empty, the default value oftallest = 0is preserved, which matches the expected behavior when no columns are specified.Testing
This edge case was not covered by existing tests. The fix ensures consistent behavior:
resizeRowsByTallestCell()→ uses viewport columns (existing)resizeRowsByTallestCell([0, 1])→ uses specified columns (existing)resizeRowsByTallestCell([])→ now correctly returns 0 height (fixed)