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 onChange on TreeSelelect #907

Merged
merged 7 commits into from
Jan 30, 2025

Conversation

dzonidoo
Copy link
Collaborator

No description provided.

@dzonidoo dzonidoo requested a review from tomaskikutis January 29, 2025 13:09
@@ -170,7 +170,7 @@ let options2 = [
]

let fetchedArr = [];
fetch('https://nominatim.openstreetmap.org/search/berlin?format=json&addressdetails=1&limit=20').then(response => response.json()).then(data => fetchedArr = data);
fetch('https://nominatim.openstreetmap.org/search.php?q=berlin&exclude_place_ids=134060781&format=jsonv2').then(response => response.json()).then(data => fetchedArr = data);
Copy link
Member

Choose a reason for hiding this comment

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

inline the values so we don't have to rely on an external API

/*
* This variable is used to distinguish changes coming from outside (from props.value)
* from those made by the user through interaction with the component.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Include in the comment is that the purpose is to prevent triggering onChange when props change.

@dzonidoo dzonidoo requested a review from tomaskikutis January 30, 2025 11:03
@@ -169,8 +169,24 @@ let options2 = [
},
]

let fetchedArr = [];
fetch('https://nominatim.openstreetmap.org/search/berlin?format=json&addressdetails=1&limit=20').then(response => response.json()).then(data => fetchedArr = data);
let fetchedArr = [
Copy link
Member

@tomaskikutis tomaskikutis Jan 30, 2025

Choose a reason for hiding this comment

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

since there's only item there, what's the point to have it at all? What about removing it completelly and simply using one of demo arrays we already have?

Copy link
Collaborator Author

@dzonidoo dzonidoo Jan 30, 2025

Choose a reason for hiding this comment

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

initial point was to present real async mode...

Copy link
Member

Choose a reason for hiding this comment

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

async demo is using a timeout to simulate a request delay and fetchedArr was being accessed synchronously. It makes no difference which data source is being used if they are both accessed synchronously

@dzonidoo dzonidoo requested a review from tomaskikutis January 30, 2025 11:26
@dzonidoo dzonidoo merged commit ecea699 into superdesk:develop Jan 30, 2025
5 checks passed
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