From f4a6a6d2aaf3b52deaa376f497b6a329f9b2a7e3 Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Sun, 15 Jul 2018 18:41:15 +1000 Subject: [PATCH] fix: Safary and Negative TabIndex, #33 --- src/Trap.js | 4 +++- stories/TextSelection.js | 21 ++++++++++++++++++++- stories/index.js | 5 +++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Trap.js b/src/Trap.js index 316e2d9..f43ce9a 100644 --- a/src/Trap.js +++ b/src/Trap.js @@ -30,7 +30,9 @@ const activateTrap = () => { if ( workingNode && !(focusInside(workingNode) || - focusIsPortaledPair(activeElement, workingNode)) + focusIsPortaledPair(activeElement, workingNode) || + (workingNode.contains && workingNode.contains(activeElement)) + ) ) { onActivation(); if (document && !lastActiveFocus && activeElement && !autoFocus) { diff --git a/stories/TextSelection.js b/stories/TextSelection.js index c824545..d959242 100644 --- a/stories/TextSelection.js +++ b/stories/TextSelection.js @@ -31,8 +31,10 @@ class Trap extends Component {

Some text + {this.props.children}
+ { Array(100).fill(1).map(x =>
{x}---
)} Some text @@ -62,8 +64,25 @@ const TextSelectionDisabled = () => ; +const TextSelectionTabIndexEnabled = () => +
+ + Some text +
+ +
+ test + + set +
+
+
+ Some text + +
; export { TextSelectionEnabled, - TextSelectionDisabled + TextSelectionDisabled, + TextSelectionTabIndexEnabled, } \ No newline at end of file diff --git a/stories/index.js b/stories/index.js index 024ed0e..b90d9ad 100644 --- a/stories/index.js +++ b/stories/index.js @@ -10,7 +10,7 @@ import TabIndex from './TabIndex'; import AutoFocus from './Autofocus'; import ReturnFocus from './ReturnFocus'; import {Trap1, Trap2, Trap3, Trap4} from './Checkboxes'; -import {TextSelectionEnabled, TextSelectionDisabled} from './TextSelection'; +import {TextSelectionEnabled, TextSelectionDisabled, TextSelectionTabIndexEnabled} from './TextSelection'; import JumpCase from './Jump'; import GroupCase from './Group'; import PortalCase from './Portal'; @@ -38,7 +38,8 @@ storiesOf('Checkboxes', module) storiesOf('Text selection', module) .add('enabled', () => ) - .add('disabled', () => ); + .add('disabled', () => ) + .add('tabindex -1', () => ); storiesOf('Jump', module) .add('jump', () => );