File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ function isTabDisabled(node) {
18
18
return node . getAttribute ( 'aria-disabled' ) === 'true' ;
19
19
}
20
20
21
+ const canUseActiveElement = ! ! ( typeof window !== 'undefined' &&
22
+ window . document &&
23
+ window . document . activeElement ) ;
24
+
21
25
export default class UncontrolledTabs extends Component {
22
26
static defaultProps = {
23
27
className : 'ReactTabs' ,
@@ -143,10 +147,14 @@ export default class UncontrolledTabs extends Component {
143
147
144
148
// Figure out if the current focus in the DOM is set on a Tab
145
149
// If it is we should keep the focus on the next selected tab
146
- const wasTabFocused = React . Children
147
- . toArray ( child . props . children )
148
- . filter ( tab => tab . type === Tab )
149
- . some ( ( tab , i ) => document . activeElement === this . getTab ( i ) ) ;
150
+ let wasTabFocused = false ;
151
+
152
+ if ( canUseActiveElement ) {
153
+ wasTabFocused = React . Children
154
+ . toArray ( child . props . children )
155
+ . filter ( tab => tab . type === Tab )
156
+ . some ( ( tab , i ) => document . activeElement === this . getTab ( i ) ) ;
157
+ }
150
158
151
159
result = cloneElement ( child , {
152
160
children : React . Children . map ( child . props . children , tab => {
You can’t perform that action at this time.
0 commit comments