mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-19 11:59:34 +00:00
feat(ToolbarBatchActions): Allow showing the toolbar even if there are no selected items.
Fixes #1438. Maintains current behavior but allows for an over-ride to ensure the toolbarbatchactions bar does not close when the user has unselected all items. Example Useage: ``` <Toolbar> <ToolbarContent> <ToolbarBatchActions show={true}> .... </ToolbarBatchActions> </ToolbarContent> </Toolbar> ```
This commit is contained in:
parent
ab5eff5205
commit
375654a283
1 changed files with 8 additions and 2 deletions
|
@ -6,12 +6,18 @@
|
||||||
export let formatTotalSelected = (totalSelected) =>
|
export let formatTotalSelected = (totalSelected) =>
|
||||||
`${totalSelected} item${totalSelected === 1 ? "" : "s"} selected`;
|
`${totalSelected} item${totalSelected === 1 ? "" : "s"} selected`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to `true` to show the ToolbarBatchActions regardless of row selection
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
export let show = false;
|
||||||
|
|
||||||
import { onMount, getContext } from "svelte";
|
import { onMount, getContext } from "svelte";
|
||||||
import Button from "../Button/Button.svelte";
|
import Button from "../Button/Button.svelte";
|
||||||
|
|
||||||
let batchSelectedIds = [];
|
let batchSelectedIds = [];
|
||||||
|
|
||||||
$: showActions = batchSelectedIds.length > 0;
|
$: showActions = batchSelectedIds.length > 0 || show;
|
||||||
|
|
||||||
const ctx = getContext("DataTable");
|
const ctx = getContext("DataTable");
|
||||||
const unsubscribe = ctx.batchSelectedIds.subscribe((value) => {
|
const unsubscribe = ctx.batchSelectedIds.subscribe((value) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue