@targetprocess/tabs 12.19.0 → 12.19.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ShowMore.jsx CHANGED
@@ -99,11 +99,6 @@ export default class ShowMore extends React.Component {
99
99
 
100
100
  const isListHidden = isHidden
101
101
 
102
- const showMoreStyles = classNames(
103
- styles['tabs__header__tabs__showmore'],
104
- hasChildSelected && styles['tabs__header__tabs__showmore--selected']
105
- )
106
-
107
102
  const listStyles = classNames(
108
103
  styles['tabs__header__tabs__showmore-menu'],
109
104
  !isListHidden && styles['tabs__header__tabs__showmore-menu--opened'],
@@ -125,32 +120,31 @@ export default class ShowMore extends React.Component {
125
120
  isOpen={!isListHidden}
126
121
  onOuterAction={this.close}
127
122
  body={
128
- <div className={listStyles} aria-hidden={isListHidden} role="menu">
123
+ <div className={listStyles} aria-hidden={isListHidden} role="tablist">
129
124
  {children}
130
125
  </div>
131
126
  }
132
127
  >
133
- <div className={styles.tabs__header__tabs__showmore__wrapper}>
134
- <div
128
+ <div
129
+ className={styles.tabs__header__tabs__showmore__wrapper}
130
+ role="tab"
131
+ aria-label="More tabs"
132
+ >
133
+ <Button
135
134
  ref={onShowMoreChanged}
136
- className={showMoreStyles}
137
- role="navigation"
138
- tabIndex="0"
139
135
  onFocus={this.onFocus}
136
+ role="navigation"
140
137
  onBlur={this.onBlur}
141
138
  onClick={this.toggleVisibility}
142
- >
143
- <Button
144
- checked={!isListHidden}
145
- className={showMoreLabelStyles}
146
- icon={<ChevronIcon />}
147
- kind="default"
148
- size="L"
149
- data-title="More tabs"
150
- noBackground
151
- isWide
152
- />
153
- </div>
139
+ checked={!isListHidden}
140
+ className={showMoreLabelStyles}
141
+ icon={<ChevronIcon />}
142
+ kind="default"
143
+ size="L"
144
+ data-title="More tabs"
145
+ noBackground
146
+ isWide
147
+ />
154
148
  </div>
155
149
  </Popover>
156
150
  )
package/TabInner.jsx CHANGED
@@ -33,6 +33,11 @@ export default class TabInner extends React.Component {
33
33
  this.props.classNames !== nextProps.classNames
34
34
  )
35
35
  }
36
+ componentDidMount() {
37
+ if (this.props.firstElement) {
38
+ this.tab.focus()
39
+ }
40
+ }
36
41
 
37
42
  blurHandler = () => {
38
43
  window.requestAnimationFrame(() => {
package/Tabs.jsx CHANGED
@@ -9,9 +9,11 @@ import styles from './style/index.css'
9
9
  import {debounce} from '../../base/utils/debounce'
10
10
  import {TabsPrint} from './TabsPrint'
11
11
  import {showMorePopoverProps} from './shared-proptype'
12
+ import _uniqueId from 'lodash/uniqueId'
12
13
 
13
14
  const tabPrefix = 'tab-'
14
15
  const panelPrefix = 'panel-'
16
+ const tablistPrefix = 'tablist-'
15
17
 
16
18
  // By itself, Tab is just a dummy component that is used for a cleaner Tabs API
17
19
  // and as marker for actual tabs to prevent storing them as huge array
@@ -34,7 +36,7 @@ Tab.propTypes = {
34
36
  *
35
37
  * Top-level `<Tabs />` can work in either controlled or uncontrolled mode.
36
38
  * In controlled mode, it uses `initialActiveTabId` to determine which
37
- * tab is open by default, and then manages manually manages changing tabs
39
+ * tab is open by default, and then manually manageschanging tabs
38
40
  * on appropriate header clicks.
39
41
  * In uncontrolled mode, it uses `activeTabId` prop to determine which tab
40
42
  * is open and exposes `onActiveTabChanged` callback that is invoked each time
@@ -74,6 +76,8 @@ export class Tabs extends React.Component {
74
76
  cacheOpenedTabs: false
75
77
  }
76
78
 
79
+ tablistId = _uniqueId(tablistPrefix)
80
+
77
81
  tabRefs = new Map()
78
82
 
79
83
  activeTabElement = null
@@ -432,11 +436,14 @@ export class Tabs extends React.Component {
432
436
  ref={tabs => (this.tabsWrapper = tabs)}
433
437
  onKeyDown={this.onKeyDown}
434
438
  className={styles.tabs__header__container}
439
+ role="tablist"
440
+ aria-labelledby={this.tablistId}
435
441
  >
436
442
  {this.props.title ? (
437
443
  <div
438
444
  className={styles.tabs__header__title}
439
445
  ref={titleWrapper => (this.titleWrapper = titleWrapper)}
446
+ id={this.tablistId}
440
447
  >
441
448
  {this.props.title}
442
449
  </div>
@@ -449,8 +456,8 @@ export class Tabs extends React.Component {
449
456
  showMorePopoverClassName={this.props.showMorePopoverClassName}
450
457
  showMorePopoverProps={this.props.showMorePopoverProps}
451
458
  >
452
- {tabsHidden.map(tab => (
453
- <TabInner {...this.getTabProps(tab)} />
459
+ {tabsHidden.map((tab, index) => (
460
+ <TabInner firstElement={index === 0} {...this.getTabProps(tab)} />
454
461
  ))}
455
462
  </ShowMore>
456
463
  </div>