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 throwing SharedToggleItem on item without label #3486

Closed
wants to merge 2 commits into from

Conversation

jagodarybacka
Copy link
Contributor

@jagodarybacka jagodarybacka commented Jun 16, 2023

What

Solve throwing NFTs filters page when some collection got undefined label. Seems like it makes SharedToggleItem throw an unexpected error. As we don't know yet how it happened that the collection had an undefined label let's make a fix in isProbablyEVMAddress

image

Latest build: extension-builds-3486 (as of Mon, 19 Jun 2023 10:13:43 GMT).

@jagodarybacka jagodarybacka self-assigned this Jun 16, 2023
@@ -25,7 +25,7 @@ export default function SharedToggleItem({
<div className="text_wrap">
<div className="thumbnail" role="img" />
<label className="label ellipsis">
{isProbablyEVMAddress(label) ? truncateAddress(label) : label}
{isProbablyEVMAddress(label) ? truncateAddress(label) : label ?? ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think what we're missing here is updating the type of label to include the possibility of undefined (and same for isProbablyEVMAddress).

@@ -8,7 +8,7 @@ import SharedToggleButton from "./SharedToggleButton"
export const STARS_GREY_URL = "./images/stars_grey.svg"

type SharedToggleItemProps = {
label: string
label?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment
I wonder if this is the correct place for the fix. 🤔 My point is that the problem is not with the SharedToggleItem component but with the undefined name value for collection. Therefore, I don't know whether we shouldn't fix this issue here. Because now the changes apply to the shared component what is a bit unclear is why the label can be optional. What I mean is that the thumbnailURL is already optional and with the optional label it reduces this component to a simple SharedToggleButton. Maybe we could add a comment for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tbh I'm now hesitant to even merging this fix, as I was not able to reproduce it and in theory the name should be replaced with empty string if needed while the collection is fetched from SH. Unless we are able to find a way to reproduce it 🤔
cc @michalinacienciala can you try to reproduce that problem with NFTs filters?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to reproduce it. A bit different steps than before: I reproduced it in Playwright tests when switching networks quickly (Ethereum -> Optymism -> Polygon -> Arbitrum) and then going straight away to NFTs filtering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have this test already in the codebase? if not can you create a draft PR with it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added temporary test in #3512.

@jagodarybacka
Copy link
Contributor Author

Ok, I've found where the problem was, it is not actually because of NFTs, it happens because the account is not fully loaded and it has no name yet but we are not providing a fallback to address. Will close this PR and open a new one.

@jagodarybacka jagodarybacka deleted the shared-toggle-fix branch June 30, 2023 09:42
Shadowfiend added a commit that referenced this pull request Jul 3, 2023
### What

Follow up for #3486

Add fallback from name to address in NFT filters. To avoid NFT filters
throwing error when the account is not yet loaded let's add a fallback
from name to address to put in the SharedToggle label.

### Testing

- [x] install extension and throttle network so it is super slow 🐌 
- [x] add account and while it is loading quickly go to NFTs and try to
click on the filters panel as soon as it is unblocked
- [x] filters panel should not throw

Latest build:
[extension-builds-3513](https://github.com/tahowallet/extension/suites/14022443935/artifacts/782867040)
(as of Mon, 03 Jul 2023 10:15:53 GMT).
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.

4 participants