Select methods for adding/removing features #16923
Conversation
…CR" on every line
…clicked (applying filters, select events)
|
I was not able to run (and therefore write) tests, every single browser test was timing out after 2500ms with Heres a longer excerpt of running the tests
|
|
📦 Preview the website for this branch here: https://deploy-preview-16923--ol-site.netlify.app/. |
ahocevar
left a comment
There was a problem hiding this comment.
Thanks for your contribution, @laundmo. I triggered the CI tests, so you can see the test results - several tests are failing.
I don't know why the tests don't run for you. Did npm install run without any issues? Does npm run karma work? Maybe your Windows installation is locked down so some browser features are blocked?
Simplifying examples is ok, but changing their behavior and thus making them more complex is not so good. A dedicated new example that shows the new features of the Select interaction would be better.
| *.js text eol=lf | ||
| *.cjs text eol=lf | ||
| *.ts text eol=lf | ||
| *.mjs text eol=lf No newline at end of file |
There was a problem hiding this comment.
Please add these settings to your local git config, not to the repository.
There was a problem hiding this comment.
well, its the repos prettier config which causes it to error on every single line with the default git settings on windows (convert LF to CRLF on pull, and back to LF on push)
i can definitely remove it, but i'd urge you to consider changing something so the default behaviour on windows when using your recommended development setup isn't errors on every single line
There was a problem hiding this comment.
A note in DEVELOPING.md, describing how to configure git locally, would be the preferred alternative. Because that's missing in our recommended development setup.
There was a problem hiding this comment.
aight, if thats what you want, i'll remove the commit. its not ideal though as this is not something which should be configured globally. And you can't configure it locally before cloning, so you'll have to:
- clone
- configure
- git rm everything
- git reset --hard
to fix the line endings. which is quite an annoyingly convoluted process for something like line endings which usually just works (as most projects don't care about having CRLF during development)
There was a problem hiding this comment.
I spent quite some time in the past trying to make Prettier accept that, but failed. If you find a way, that's ok for me too.
There was a problem hiding this comment.
You may also want to weigh in on #16597. As I said there, I'm not opposed to that change, so maybe it's time to merge that and you can rebase this pull request and get what you envisioned.
Yup, no issues there
haven't tried that, what i've tried is the code-only tests, which worked fine.
Not to my knowledge. Its not joined to a Domain, theres no group policies, its a relatively standard windows install.
do you just mean the fact i added a filter to the box select example, the fact i swapped it over to using the new methods at all, or something else? please be specific, that way i know exactly what you have an issue with. |
ahocevar
left a comment
There was a problem hiding this comment.
Regarding the examples, you convinced me. Now please focus on making the tests pass. The hints in the CI output should help, even if you're not able to run the tests locally, for whatever reason.
| *.js text eol=lf | ||
| *.cjs text eol=lf | ||
| *.ts text eol=lf | ||
| *.mjs text eol=lf No newline at end of file |
There was a problem hiding this comment.
A note in DEVELOPING.md, describing how to configure git locally, would be the preferred alternative. Because that's missing in our recommended development setup.
|
I think i found why browser test are failing: karma-runner/karma#251 seems Karma doesn't handle absolute paths on Windows at all, since 2012? I am seeing the same kind of URL error from that issue in some stacktraces: edit: nope, doesn't seem likely, as the js modules seem to load fine, its the assets/data (images etc) which are failing |
|
Okay i finally found out the main issue with tests: It seems that by default, Windows resolves This means only the proxied paths, where the karma server was making a request to itself after rewriting the URL, it tried to request for example Turns out, one fix for this is explicitly setting the hostname to the IPv4 |
|
tests should be fixed now, and i added tests for the new methods |
|
Oh, you merged the .gitattributes stuff too, nice. i was wondering when i'd have time to remove that commit... thanks for merging! |
This PR fixes #16918 and fixes #16597
by adding the following (public) methods to the Select interaction:
selectFeature(feature)- selects a feature as if the user clicked it, only if it passes the filters (layer and filter function). sends a SelectEvent if its selecteddeselectFeature(feature)- deselects a feature if its currently selected, sending a SelectEvent if it got deselectedtoggleFeature(feature)- toggles a feature on and off, sends a SelectEvent depending on what happenedclearSelection()- remove all features from selection, sends a SelectEvent with all of them in .deselectedTo accomplish this, i've added some private methods and migrated the mapBrowserEvent handling code to using them.
Examples are updated, i've utilized more features of Select for some of them.
Tests aren't run yet, due to issues (see below)