-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix getFacetedMinMaxValues #5676
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit dbaaa72. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
|
||
for (let j = 0; j < values.length; j++) { | ||
const value = values[j]! | ||
let facetedMinValue = uniqueValues.at(0)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to only use es2020 syntax here
I noticed a bug in getFacetedMinMaxValues that I'm surprised no one else has reported or the type checks haven't flagged. Actually, I'm sure I've run into this issue before, but I guess I never got around to reporting it...
The
getUniqueValues
function says it returns (and in testing, does return) an array of values. Thus,firstValue
becomes e.g.[123]
, andfacetedMinMaxValues
will get initialized to[[123], [123]]
, which sometimes results in the function returning e.g.[123, [123]]
, depending on the row values. I'm guessing people don't always notice a bug here because an array is being<
/>
compared to a numbe, which I think coerces the array to a string?My first commit makes the minimal change that I think fixes the issue. The second commit reworks the function to be a bit safer imo.