Skip to content
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(data-grid): prevents null or undefined break max content length calculation #2377

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NOMADE55
Copy link

@NOMADE55 NOMADE55 commented Dec 19, 2024

What does this PR do?

Quick summary

Data Grid component calculates the longest row. For this it relies on .toString() method to obtain its length.
Both null and undefined lack the former one, and will break the component after invoking the method.

What has been done

  • Add to 0 as default-
  • optional chaining to prevent these values from breaking the component.

Some Observations

  • This is my first PR here 👋🏻 so if I'm missing something let me know.
  • I'm still figuring lerna and this monorepo out, so any observations are welcome.
  • Tested locally in a mock project.

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for marvelous-moxie-a6e2fe ready!

Name Link
🔨 Latest commit 8ce3a45
🔍 Latest deploy log https://app.netlify.com/sites/marvelous-moxie-a6e2fe/deploys/6763a86cf40df400089a5922
😎 Deploy Preview https://deploy-preview-2377--marvelous-moxie-a6e2fe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@amir-ba amir-ba left a comment

Choose a reason for hiding this comment

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

@NOMADE55 thanks for this change but IMHO we still need to consider the sorting as well.
it would be enough for now to add optional chaining (.?) to the sortTabe function on line 473-474 and 479-480

  const textA = a[columnIndex]?.toLowerCase();
  const textB = b[columnIndex]?.toLowerCase();

@NOMADE55
Copy link
Author

NOMADE55 commented Jan 24, 2025

@amir-ba Sorry, maybe I'm not following, the error seems to happen when trying to get the longest content.
If a value is undefined or null, shouldn't its length be zero?

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.

2 participants