Skip to content

Commit edf9667

Browse files
cal-smithasudoh
authored andcommitted
fix(table): regression fixes (#2356)
- add support for actions that aren't overflow menus - add support for inital v10 style search
1 parent 37a7667 commit edf9667

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

packages/components/src/components/data-table/_data-table-action.scss

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
visibility $duration--fast-02 motion(standard, productive);
3636
}
3737

38+
//-------------------------------------------------
39+
//DEPRECATED v10/v9 search behaviour
40+
//-------------------------------------------------
41+
.#{$prefix}--batch-actions ~ .#{$prefix}--toolbar-search-container {
42+
opacity: 1;
43+
transition: opacity 110ms;
44+
display: flex;
45+
align-items: center;
46+
}
47+
3848
//-------------------------------------------------
3949
//HIDDEN SEARCH - DEFAULT TOOLBAR
4050
//-------------------------------------------------
@@ -166,7 +176,9 @@
166176
//-------------------------------------------------
167177
//TOOLBAR BUTTONS
168178
//-------------------------------------------------
169-
.#{$prefix}--overflow-menu.#{$prefix}--toolbar-action {
179+
.#{$prefix}--overflow-menu.#{$prefix}--toolbar-action,
180+
// DEPRECATED prefer .#{$prefix}--overflow-menu.#{$prefix}--toolbar-action instead
181+
.#{$prefix}--toolbar-action {
170182
@include button-reset;
171183
display: flex;
172184
cursor: pointer;

packages/components/src/components/data-table/data-table.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,5 +486,34 @@ module.exports = {
486486
sort: true,
487487
},
488488
},
489+
{
490+
name: 'compat',
491+
label: 'Data Table (with deprecated toolbar search and actions)',
492+
notes: `
493+
Data Tables are used to represent a collection of resources, displaying a
494+
subset of their fields in columns, or headers.
495+
`,
496+
context: {
497+
state: 'compat',
498+
title: 'Table title',
499+
optionalHelper: 'Optional Helper Text',
500+
batchActions,
501+
toolbarActions,
502+
columns,
503+
rows,
504+
selectedItemsCounterLabel: `
505+
<span data-items-selected>3</span> items selected
506+
`,
507+
searchInputId: 'search__input-2',
508+
searchLabelId: 'search-input-label-1',
509+
searchLabel: 'Search',
510+
clearSearchLabel: 'Clear search input',
511+
addNewLabel: 'Add new',
512+
cancelLabel: 'Cancel',
513+
sortLabel: 'Sort rows by this header in descending order',
514+
hasToolbar: true,
515+
sort: true,
516+
},
517+
},
489518
],
490519
};

packages/components/src/components/data-table/data-table.hbs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@
3737
</div>
3838
{{/if}}
3939

40+
{{#is state "compat"}}
41+
<div class="{{@root.prefix}}--toolbar-search-container">
42+
<div data-search class="{{@root.prefix}}--search {{@root.prefix}}--search--sm" role="search">
43+
<div class="{{@root.prefix}}--search-magnifier" tabindex="0">
44+
{{ carbon-icon 'Search16' class=(add @root.prefix '--toolbar-action__icon')}}
45+
</div>
46+
<label id="{{searchLabelId}}" class="{{@root.prefix}}--label" for="{{searchInputId}}">{{searchLabel}}</label>
47+
<input class="{{@root.prefix}}--search-input" type="text" id="{{searchInputId}}" role="search"
48+
placeholder="{{searchLabel}}" aria-labelledby="{{searchLabelId}}">
49+
<button class="{{@root.prefix}}--search-close {{@root.prefix}}--search-close--hidden" title="{{clearSearchLabel}}"
50+
aria-label="{{clearSearchLabel}}">
51+
{{ carbon-icon 'Close16'}}
52+
</button>
53+
</div>
54+
</div>
55+
{{/is}}
56+
4057
{{#if toolbarActions}}
4158
<div class="{{@root.prefix}}--toolbar-content">
4259
<!-- Default hidden search -->
@@ -90,6 +107,16 @@
90107
</div>
91108
{{/each}}
92109

110+
<!-- Legacy toolbar actions-->
111+
{{#is state "compat"}}
112+
{{#each toolbarActions as |toolbar|}}
113+
<div class="{{@root.prefix}}--toolbar-action" role="button"
114+
tabindex="0" aria-label="Overflow" aria-haspopup="true" aria-expanded="false">
115+
{{{ toolbar.icon }}}
116+
</div>
117+
{{/each}}
118+
{{/is}}
119+
93120
<!-- Toolbar primary button -->
94121
<button class="{{@root.prefix}}--btn {{@root.prefix}}--btn--sm {{@root.prefix}}--btn--primary">
95122
{{#if small }} Primary {{else}} Primary Button {{/if}}

0 commit comments

Comments
 (0)