| 19:33 | mstenta[m] | symbioquine paul121 I think I found a small bug, curious your thoughts... |
| 19:33 | mstenta[m] | github.com/farmOS/farmOS/blob/a13a0de10a |
| 19:33 | mstenta[m] | Should that be passing element.id instead of element to farmOS.map.create()? |
| 19:34 | mstenta[m] | I discovered this because I was trying to use farmOS.map.targetIndex(id) to look up an instance by ID, but it didn't work... because instance.target was being set to the whole element instead of just the ID |
| 19:35 | mstenta[m] | Changing element to element.id fixed it... and everything seems to be working. I can open a PR, I just wanted to check to see if you think that's correct, or if there are any other considerations... |
| 19:42 | paul121[m] | huh, yeah that makes sense. i didn't realize we had that farmOS.map.targetIndex() helper |
| 19:43 | paul121[m] | I guess OL must accept an ID or the actual element? |
| 19:49 | mstenta[m] | Yea I guess so |
| 20:09 | symbioquine[m] | No, it's better for that function (createMapInstance) to accept the element not the id. That means it can be used in scenarios where the target element doesn't have an id - e.g. a map instance creating by Vue/React/etc. |
| 20:10 | symbioquine[m] | Otherwise, you'd be forced to generate some kind of id just to use the function where you wouldn't otherwise need one - e.g. multiple instances of maps on the same page or maps within dialogs that are created/dismissed in an ad hoc manner. |
| 20:12 | symbioquine[m] | Passing the HTMLElement is one of the standard ways of instantiating a OL Map object: openlayers.org/en/latest/apidoc/module-o |
| 20:13 | mstenta[m] | Ah hmm OK so maybe we need to rethink farmOS.map.targetIndex() |
| 20:14 | mstenta[m] | (Or remove it entirely) |
| 20:14 | symbioquine[m] | Do we? |
| 20:14 | symbioquine[m] | It looks like the only thing that needs updating is the doc string for the fn... |
| 20:14 | symbioquine[m] | github.com/farmOS/farmOS-map/blob/4e3800 |
| 20:14 | symbioquine[m] | Should also work if passed an element right? |
| 20:15 | mstenta[m] | Yea maybe |
| 20:15 | symbioquine[m] | I'd need to test, but I think comparing element instances with === should work. |
| 20:17 | symbioquine[m] | github.com/symbioquine/farmOS_land_drawi |
| 20:18 | mstenta[m] | Just to clarify, I wasn't suggesting we change what's passed to Drupal.behaviors.farm_map.createMapInstance() - that would still be an element |
| 20:19 | mstenta[m] | Here's the PR I opened (just before I saw your chats): github.com/farmOS/farmOS/pull/672 |
| 20:19 | symbioquine[m] | ^ Assumes the passed element has an id though. |
| 20:19 | mstenta[m] | That's true - that was the original assumption in farmOS-map, but no longer necessary I guess |
| 20:19 | mstenta[m] | (Back when targetIndex() was added) |
| 20:20 | mstenta[m] | (Closed that PR) |
| 20:20 | symbioquine[m] | mstenta[m]: Agreed. Seems like there's actually a few places in the farmOS-map docs that should be updated to reflect that we just pass the input through to OL - thus can accept the same argument types. |
| 20:23 | mstenta[m] | > I'd need to test, but I think comparing element instances with `===` should work. |
| 20:23 | mstenta[m] | Confirmed that this works 👍️ |
| 20:27 | toino[m] | Wtf |
| 20:27 | symbioquine[m] | > <@mstenta:matrix.org> > I'd need to test, but I think comparing element instances with `===` should work.... (full message at <libera.ems.host/_matrix/media/v3/downloa>) |
| 20:28 | symbioquine[m] | ^ Tested the scenario that === doesn't somehow depend on having an id set for HTMLElement. |
| 23:28 | * | farmBOT has joined |