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

Enhancement: Add closable functionality to calcite-tabs-title #2620

Closed
am-maneaters opened this issue Jul 23, 2021 · 26 comments
Closed

Enhancement: Add closable functionality to calcite-tabs-title #2620

am-maneaters opened this issue Jul 23, 2021 · 26 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. design Issues that need design consultation prior to development. enhancement Issues tied to a new feature or request. estimate - 3 A day or two of work, likely requires updates to tests. p - high Issue should be addressed in the current milestone, impacts component or core functionality ready for dev Issues ready for development implementation.

Comments

@am-maneaters
Copy link

Description

Add action button to the calcite-tab-title component to allow for closing tabs

*Obviously very rough implementation below
image

Acceptance Criteria

Include action button in tabs with custom icons and custom onClick event

Relevant Info

Which Component

calcite-tab-title

Example Use Case

Allow users to close opened tabs using the action button in the tab titles

@am-maneaters am-maneaters 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 Jul 23, 2021
@jcfranco jcfranco added this to the Backlog milestone Jul 29, 2021
@jcfranco jcfranco removed the needs triage Planning workflow - pending design/dev review. label Aug 11, 2021
@benelan benelan mentioned this issue May 10, 2022
@AdamWMoqrane
Copy link

Hello! XI Design would definitely have a need for this issue with the Knowledge Studio project we are working on. Prioritizing this would help many out!

@macandcheese macandcheese added the design Issues that need design consultation prior to development. label Jun 29, 2022
@RSantosGIS
Copy link

Just wanted to bump this requirement from the ArcGIS Knowledge Studio team again following our conversation with Adam T. yesterday.

@macandcheese
Copy link
Contributor

@macandcheese macandcheese changed the title Enhancement: Add action button to calcite-tabs-title Enhancement: Add dismiss / close functionality to calcite-tabs-title Dec 7, 2022
@lkoumis
Copy link

lkoumis commented Jan 26, 2023

Similar to the attribute table in web appbuilder, it would be a great feature to be able to add a tab containing the feature table of a loaded layer and then be able to remove the tab when the layer is removed from the map.

@macandcheese
Copy link
Contributor

macandcheese commented Feb 13, 2023

@geospatialem @jcfranco - this is high-impact for Knowledge Studio and other teams and matches existing closable pattern in components like Alert, Notice, Panel, Chip, etc.

@macandcheese macandcheese changed the title Enhancement: Add dismiss / close functionality to calcite-tabs-title Enhancement: Add closable functionality to calcite-tabs-title Feb 13, 2023
@geospatialem geospatialem added the estimate - 3 A day or two of work, likely requires updates to tests. label Feb 22, 2023
@geospatialem geospatialem added 1 - assigned Issues that are assigned to a sprint and a team member. and removed 0 - new New issues that need assignment. labels Feb 22, 2023
@geospatialem geospatialem added the p - high Issue should be addressed in the current milestone, impacts component or core functionality label Mar 3, 2023
@geospatialem
Copy link
Member

Should consider with the efforts of #2721, anticipated for the May 2023 milestone.

@ashetland
Copy link
Contributor

Quick question about behavior on this as we work out details. I would expect [closable] to be globally set, e.i. all tabs are closable or not-closable. This way we would avoid a confusing possible state of mixed closable and non-closable tabs. Does this thinking jive with expectations?

@macandcheese
Copy link
Contributor

I’d imagine it would be more flexible to set per tab.

Perhaps the tabs represent tables or sheets, and the app has a minimum number to display, or for the same workflow, some tabs are locked due to permission (and denoted as such with icon-start/end).

Those are just two use cases that come to mind but I’d expect some other similar needs.

Some related questions:
Should we allow the last tab to be closed?

Should we consider allowing tabs to be re-ordered (log as separate enhancement). If tabs can be closed, we can imagine they may be used in workflows where users could reorder the representative tabs.

@geospatialem
Copy link
Member

Reallocating to the April milestone.

@ashetland
Copy link
Contributor

@geospatialem, final designs are ready in the Figma enhancements folder and had a walkthrough chat today with Eliza. The Figma branch should get merged this week so designers can start playing with it.

@AdamWMoqrane
Copy link

Yay! Thanks Aaron, we are looking forward to using this!

@RSantosGIS
Copy link

Thanks for working on this! We are definitely glad to not have to custom roll this as an extended capability in Studio

@Elijbet
Copy link
Contributor

Elijbet commented Mar 29, 2023

I have a lingering question regarding what happens when we close a tab. As in does closing tab 3 mean we get tab 4 selected (tab 4 contents displayed) after tab 3 and its contents are gone?

Or do we let it refocus to default: tab 1 with its contents displayed?

@SkyeSeitz @ashetland @macandcheese

@macandcheese
Copy link
Contributor

macandcheese commented Mar 29, 2023

I'd expect the previous tab to be focused and open, similar to how closing a Sheet in Excel opens the previous Sheet and makes that Tab active (they don't have a close button, but you can right click to select from menu).

For example if I close tab 4, tab 3 would be open / focus on tab title.

This also follows how it is set up in upcoming Chip Group - if you close a chip, the previous chip gains focus.

@SkyeSeitz
Copy link

My expectation was for the next tab to be focused and opened rather than the previous, but I could see either way as long as we are consistent 👍🏽

@lkoumis
Copy link

lkoumis commented Mar 30, 2023

Like how it was implemented on the Attribute table of the Web AppBuilder, if tab3 closes, then tab4 will be selected and show its contents. If tab 4 then tab3 will be selected. So, the tab to be closed, the tab to its right will get focus, if the rightmost tab closes then the tab to its left will be focused, and if the leftmost tab closes, the tab to its right will be focused,

@Elijbet
Copy link
Contributor

Elijbet commented Mar 30, 2023

My expectation was for the next tab to be focused and opened rather than the previous, but I could see either way as long as we are consistent 👍🏽

I think this is problematic when the closed tab is the last tab. And since we decided that the first tab cannot be closed if it's the last remaining one, the previous tab being focused makes more sense to me.

This will simplify the logic or we'll have to swap direction at the edges.

@ashetland
Copy link
Contributor

ashetland commented Mar 30, 2023

Like how it was implemented on the Attribute table of the Web AppBuilder, if tab3 closes, then tab4 will be selected and show its contents. If tab 4 then tab3 will be selected. So, the tab to be closed, the tab to its right will get focus, if the rightmost tab closes then the tab to its left will be focused, and if the leftmost tab closes, the tab to its right will be focused,

This feels like the correct approach with the best ux. See this video of Chrome tabs as a demonstration.
Using our 4-tabs model:

  • Closing a background tab does not change my current tab or focus
  • If tab 1 is active and closed, tab 2 becomes active
  • If tab 3 is active and closed, tab 4 becomes active
  • If tab 4 is active and closed, tab 3 becomes active
CleanShot.2023-03-30.at.08.04.59.mp4

@geospatialem geospatialem removed the design Issues that need design consultation prior to development. label Apr 3, 2023
@Elijbet Elijbet added 2 - in development Issues that are actively being worked on. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels Apr 6, 2023
@ashetland
Copy link
Contributor

Adding link to the final spec in Figma for reference.
https://www.figma.com/file/xly5vekrCnx7AH0e4D4ueM/Closable-Tabs-%5Bissue-2620%5D?node-id=1-2

@geospatialem geospatialem added the ready for dev Issues ready for development implementation. label Apr 18, 2023
@geospatialem
Copy link
Member

Migrating to the May release for implementation.

Elijbet added a commit that referenced this issue May 22, 2023
…b-titles` (#6740)

**Related Issue:** #2620

## Summary
`handleTabTitleClose` sequence is as follows:
> if `closed` item is `selected`, fall back on the next
> unless it's the last item, which falls back on previous
> closing non-selected items doesn't affect the `selected` tab
> last remaining item becomes `disabled`, if `closable`

- Added `closed` property
- Added `closable` property
- Added `calciteInternalTabsClose` event
- Added `calciteTabsClose` event
- Added t9n messages for `Close` text.
- Updated styling per new Figma specs
- Added tests

`handleTabTitleClose` keeps track of `visibleTabTitlesIndices` instead
of having Dom queries filter out `hidden`. This helps to sync `tabs`
with `tab-titles` using their corresponding `id`s set on the original
render. `visibleTabIndeces` is an array of `id`s of the non-hidden
`tab-titles`. When `tab-title` is `closed` this `id` is used to navigate
to the next visible item. This makes figuring out what the next item
should be when closing out of order is now more straightforward.

Tests coverage for 

- simple closing behavior 
- closing sequence behavior:
> - when closing `tab-titles` in sequence 1 (first selected) through 4,
`tab-title` and corresponding `tab` become hidden, and selection
fallback is the next tab
> - reverse fallback: when closing `tab-titles` in sequence 4 (last
selected) through 1, `tab-title` and corresponding `tab` become hidden,
and selection fallback is the previous tab
> - closing an unselected `tab-title` does not deselect the current
selection
> - 2 additional cases: works with a randomized closing sequence with
mixed selected and not

---------

Co-authored-by: Matt Driscoll <[email protected]>
Co-authored-by: JC Franco <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anveshreddy mekala <[email protected]>
Co-authored-by: jona7150 <[email protected]>
Co-authored-by: Kitty Hurley <[email protected]>
@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 2 - in development Issues that are actively being worked on. labels May 22, 2023
@geospatialem
Copy link
Member

geospatialem commented May 22, 2023

Verified on master with the tab-title's closable and closed attributes, and the calciteTabsClose event.

A follow-up issue will be created shortly to mitigate the high contrast color of the closable button.

<!-- HTML structure -->
<calcite-tab-nav scale="m">
  <calcite-tab-title selected closable tab="one">Tab 1 Title</calcite-tab-title>
  <calcite-tab-title closed closable tab="two">Tab 2 Title</calcite-tab-title>
  <calcite-tab-title closable tab="three">Tab 3 Title</calcite-tab-title>
</calcite-tab-nav>
</div>

<!-- JavaScript event -->
<script>
const tabNav = document.querySelector("calcite-tab-nav");

tabNav.addEventListener("calciteTabsClose", (evt) => {
  console.log(evt.target.tab);
});
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. design Issues that need design consultation prior to development. enhancement Issues tied to a new feature or request. estimate - 3 A day or two of work, likely requires updates to tests. p - high Issue should be addressed in the current milestone, impacts component or core functionality ready for dev Issues ready for development implementation.
Projects
None yet
Development

No branches or pull requests