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 removal of render features from vector source #15827

Merged
merged 3 commits into from
May 15, 2024

Conversation

sebakerckhof
Copy link
Contributor

Render features were not fully removed because they don't have change keys and can be arrays.
I look at the uindex now instead of the change keys

Copy link

📦 Preview the website for this branch here: https://deploy-preview-15827--ol-site.netlify.app/.

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Thanks, @sebakerckhof. I added a few suggestions.

src/ol/source/Vector.js Outdated Show resolved Hide resolved
Comment on lines 1127 to 1132
if (!featureChangeKeys) {
return;
if (featureChangeKeys) {
Copy link
Member

Choose a reason for hiding this comment

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

We usually keep the happy path aligned as far left as possible, so it would be preferable to keep the logic that returns early when there ar no featureChangeKeys.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we can't return early because renderfeatures don't have change keys.
I could check for !featureChangeKeys && feature instanceof Feature though if you prefer

Copy link
Member

Choose a reason for hiding this comment

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

Yes please, that would make the code easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, an early return also doesn't make sense here since !featureChangeKeys && feature instanceof Feature can never happen anymore due to the introduction of the uidIndex check at the top.
So I just removed the if clause and added optional chaining on the featureChangeKeys.foreach.

sebakerckhof and others added 2 commits May 14, 2024 22:52
Co-authored-by: Andreas Hocevar <andreas.hocevar@gmail.com>
Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Thanks, @sebakerckhof

@ahocevar ahocevar merged commit 78a22e7 into openlayers:main May 15, 2024
8 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.

None yet

2 participants