Select to view content in your preferred language

New Map Component UI Simplification (use slots)

219
2
07-18-2024 12:08 AM
Status: Open
Labels (2)
GeoGalvanic
New Contributor II

I've been using the new map components for a little bit now and have run into sometimes annoying complications where widget placement/behavior isn't entirely predictable.

 

Right now as best I've been able to figure out a widget can be added to a map with the following methods:

1. As a direct child of a map-component using the "position" property to place it in one of the four UI corners, or manually placing it*.

2. As a direct child of an expand component that is itself a direct child of a map component

3. As a child (at most 2 deep) of a placement component that is a direct child of one of the 2 above components

4. By programmatically adding the widget to one of the above components

Additionally the widget component isn't actually moved in the UI, instead the widget interface is defined as the component's "childElem" property (which is not documented) and then that childElem is moved into the UI. If using manual placement* then moving the widget component into a new container breaks the interface. Instead the component's childElem needs to moved into the container, which is not very intuitive.

 

Instead, I think that it would be better if the map ui sections were slots and map widgets/expands were slottables that could be placed in them. This behavior would be more consistent with the calcite components and with web components overall.

IF a widget component isn't slotted it should instead instantiate it's interface element directly under the component's shadow dom (as that is the most predictable behavior). The referenceComponent should be the closest parent map/scene component, that way they can be nested as deep as desired. If there is no reference component defined/available, the widget interface should still be instantiated so that the map/view link can be established programmatically while the widget component is placed wherever desired.

 

I'm not sure that I've got the current behavior pegged down exactly, but that really only serves to show how complicated the interactions are right now.

Tags (1)
2 Comments
ReneRubalcava

Thanks for the feedback! Slots are on our roadmap, but we have some under-the-hood work to do first before that can happen. Some things such as the `childElem` you pointed out are not documented because they could change or go away in a future release. There is not set release for this work though, but when it is, we'll be talking about it!

GeoGalvanic

@ReneRubalcava Great to hear that slots are coming, I hoped that would be the case. I kind of figured that refactoring from the original widget implementation might be the reason slots weren't used yet.

 

👍