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

Option to change checkbox behaviour in tree with selectionMode="ancestors" #3608

Open
moosetraveller opened this issue Dec 1, 2021 · 4 comments
Labels
0 - new New issues that need assignment. blocked This issue is blocked by another issue. c-tree Issues that pertain to the calcite-tree and related components enhancement Issues tied to a new feature or request.
Milestone

Comments

@moosetraveller
Copy link

moosetraveller commented Dec 1, 2021

Description

At the moment, when using a tree with selectionMode="anchestors", I cannot add action buttons to a calcite-tree-item and, since everything is within a label, it's a pain to format the item.

Ways to solve this:

Workarounds

Use Event.stopPropagation() in action button's click event handler to stop event propagation. (not yet tested)

Acceptance Criteria

see description

Relevant Info

Which Component

Tree

Example Use Case

I would like to provide actions to the user (for example: zoom to layers extent, show metadata in a dialog and so on). In my workflow, a user selects data for a geoprocessing service and would like to have a peek on the data or read the metadata before continuing.

image

@moosetraveller moosetraveller added 0 - new New issues that need assignment. enhancement Issues tied to a new feature or request. needs triage Planning workflow - pending design/dev review. labels Dec 1, 2021
@moosetraveller moosetraveller changed the title Option to change checkbox behaviour in tree with ancestors Option to change checkbox behaviour in tree with selectionMode="ancestors" Dec 1, 2021
@moosetraveller
Copy link
Author

moosetraveller commented Dec 1, 2021

Workaround

Here is a workaround to use buttons inside the tree:

<calcite-tree selection-mode="ancestors" lines>
    <calcite-tree-item *ngFor="let ds of datasets;">
        {{ds.label}}
        <calcite-tree slot="children">
            <div *ngFor="let data of ds.data;" style="display: flex;">
                <calcite-tree-item [attr.value]="data.id" style="flex-grow: 5; margin-left: 0.25rem;">
                    {{data.label}}
                </calcite-tree-item>
                <!-- "focus border" of the buttons will be wrong -->
                <calcite-button (click)="zoomTo(data.id)" style="margin-left: 0.25rem;" color="neutral" 
                                 icon-start="layer-zoom-to" appearance="transparent"></calcite-button> 
                <calcite-button (click)="showInfo(data.id)" style="margin-left: 0.25rem;" color="neutral" 
                                 icon-start="information" appearance="transparent"></calcite-button>
            </div>
        </calcite-tree>
    </calcite-tree-item>
</calcite-tree>
// _tree is a reference to the tree element instance (HTMLCalciteTreeElement)
_tree.addEventListener('calciteTreeSelect', (event: any) => {

  let selection = event.detail.selected.map((selection: HTMLCalciteTreeItemElement) => {
    return selection.getAttribute("value");
  })
  .filter((value: string) => {
    return value != null;
  });

  // do something with selection

});

Note: I am using Angular.

image

@macandcheese
Copy link
Contributor

@asangma seems like a good place for the "list item slot paradigm" with slots for content-end.

@moosetraveller
Copy link
Author

Related #3127

@benelan benelan removed the needs triage Planning workflow - pending design/dev review. label Dec 14, 2021
@benelan benelan added this to the Sprint 01/03 - 01/14 milestone Dec 14, 2021
@jcfranco
Copy link
Member

This depends on #2884.

@benelan benelan added this to the Discussions milestone Apr 20, 2022
@macandcheese macandcheese added the c-tree Issues that pertain to the calcite-tree and related components label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new New issues that need assignment. blocked This issue is blocked by another issue. c-tree Issues that pertain to the calcite-tree and related components enhancement Issues tied to a new feature or request.
Projects
None yet
Development

No branches or pull requests

6 participants