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: trigger featureChanged on feature props change #1201

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

petermoz
Copy link
Contributor

@petermoz petermoz commented Oct 4, 2023

#1196 intended to add a call to featureChanged any time a feature was add()ed with modified properties, however it has a bug in that the check came after assignment.

An alternative to this fix would be to move the assignment inside the if() body, but that could break other code that depended on referential equality after calling add().

I verified the fix by hacking the demo to include a button which modified a property on a feature, and also hacked the stylesheet to render that property as a label. Code here: petermoz@132d2d2

I had a look at adding tests but couldn't figure out how to best get access to store.getChangedIds from the the API test. Happy to add tests if you have a suggestion about accessing the store.

mapbox#1196 intended to add a call to
`featureChanged` any time a feature was `add()`ed with modified
properties, however it has a bug in that the check came after assignment.

A simpler fix would be to move the assignment inside the `if()` body,
but that could break other code that depended on referential equality
after calling `add()`.
@frodare
Copy link

frodare commented Dec 6, 2023

This is an issue I have run into as well, and I believe this PR would fix it. Any chance this PR could get reviewed and merged?

@cameronb23
Copy link

Hey, we are also having trouble with features not rerendering on property changes, is there plans to get this PR merged?

@petermoz
Copy link
Contributor Author

petermoz commented Dec 9, 2023

I'd also like to see this reviewed and merged, but I think we're waiting on a project maintainer for the next step. Happy to do whatever is needed on my side

Copy link
Contributor

@stepankuzmin stepankuzmin left a comment

Choose a reason for hiding this comment

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

Good catch, @petermoz. Thanks for the contribution! This looks good to me 👍

@stepankuzmin stepankuzmin merged commit e3cb6bc into mapbox:main Dec 11, 2023
1 check passed
danielsippel added a commit to danielsippel/mapbox-gl-draw that referenced this pull request Apr 17, 2024
danielsippel added a commit to danielsippel/mapbox-gl-draw that referenced this pull request Apr 18, 2024
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.

5 participants