Skip to content

Commit

Permalink
fix: nested portals
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Jan 22, 2019
1 parent d78cc2e commit 9878ba7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"chai": "^4.1.0",
"chai-enzyme": "^1.0.0-beta.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-adapter-react-16": "^1.7.1",
"eslint": "^4.2.0",
"eslint-config-airbnb": "15.1.0",
"eslint-plugin-import": "^2.7.0",
Expand Down
17 changes: 15 additions & 2 deletions src/Lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class FocusLock extends Component {
if (this.state.observed && this.props.onActivation) {
this.props.onActivation(this.state.observed);
}
this.isActive = true;
};

onDeactivation = () => {
this.isActive = false;
if (
this.props.returnFocus &&
this.originalFocusedElement &&
Expand All @@ -47,11 +49,22 @@ class FocusLock extends Component {
}
};

onFocus = (event) => {
if (this.isActive) {
onFocus(event);
}
};

onBlur = onBlur;

setObserveNode = observed =>
this.setState({
observed,
});

// active status is tracked outside React state
isActive = false;

update = () =>
this.setState(prevState => ({
escapeAttempts: prevState.escapeAttempts + 1,
Expand Down Expand Up @@ -98,8 +111,8 @@ class FocusLock extends Component {
ref={this.setObserveNode}
{...lockProps}
className={className}
onBlur={onBlur}
onFocus={onFocus}
onBlur={this.onBlur}
onFocus={this.onFocus}
>
<FocusTrap
observed={observed}
Expand Down
59 changes: 23 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4509,27 +4509,28 @@ entities@^1.1.1, entities@~1.1.1:
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
integrity sha1-blwtClYhtdra7O+AuQ7ftc13cvA=

enzyme-adapter-react-16@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.1.1.tgz#a8f4278b47e082fbca14f5bfb1ee50ee650717b4"
integrity sha512-kC8pAtU2Jk3OJ0EG8Y2813dg9Ol0TXi7UNxHzHiWs30Jo/hj7alc//G1YpKUsPP1oKl9X+Lkx+WlGJpPYA+nvw==
enzyme-adapter-react-16@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.7.1.tgz#c37c4cb0fd75e88a063154a7a88096474914496a"
integrity sha512-OQXKgfHWyHN3sFu2nKj3mhgRcqIPIJX6aOzq5AHVFES4R9Dw/vCBZFMPyaG81g2AZ5DogVh39P3MMNUbqNLTcw==
dependencies:
enzyme-adapter-utils "^1.3.0"
lodash "^4.17.4"
object.assign "^4.0.4"
enzyme-adapter-utils "^1.9.0"
function.prototype.name "^1.1.0"
object.assign "^4.1.0"
object.values "^1.0.4"
prop-types "^15.6.0"
react-reconciler "^0.7.0"
prop-types "^15.6.2"
react-is "^16.6.1"
react-test-renderer "^16.0.0-0"

enzyme-adapter-utils@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.3.0.tgz#d6c85756826c257a8544d362cc7a67e97ea698c7"
integrity sha512-vVXSt6uDv230DIv+ebCG66T1Pm36Kv+m74L1TrF4kaE7e1V7Q/LcxO0QRkajk5cA6R3uu9wJf5h13wOTezTbjA==
enzyme-adapter-utils@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.9.1.tgz#68196fdaf2a9f51f31603cbae874618661233d72"
integrity sha512-LWc88BbKztLXlpRf5Ba/pSMJRaNezAwZBvis3N/IuB65ltZEh2E2obWU9B36pAbw7rORYeBUuqc79OL17ZzN1A==
dependencies:
lodash "^4.17.4"
object.assign "^4.0.4"
prop-types "^15.6.0"
function.prototype.name "^1.1.0"
object.assign "^4.1.0"
prop-types "^15.6.2"
semver "^5.6.0"

enzyme@^3.3.0:
version "3.3.0"
Expand Down Expand Up @@ -8050,7 +8051,7 @@ object-is@^1.0.1:
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.0.1.tgz#0aa60ec9989a0b3ed795cf4d06f62cf1ad6539b6"
integrity sha1-CqYOyZiaCz7Xlc9NBvYs8a1lObY=

object-keys@^1.0.10, object-keys@^1.0.11, object-keys@^1.0.8:
object-keys@^1.0.11, object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
integrity sha1-xUYBd4rVYPEULODgG8yotW0TQm0=
Expand All @@ -8062,15 +8063,6 @@ object-visit@^1.0.0:
dependencies:
isobject "^3.0.0"

object.assign@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc"
integrity sha1-scnMBE7xuf5jYG/BQau7MuFHMMw=
dependencies:
define-properties "^1.1.2"
function-bind "^1.1.0"
object-keys "^1.0.10"

object.assign@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da"
Expand Down Expand Up @@ -9156,6 +9148,11 @@ react-inspector@^2.3.0:
babel-runtime "^6.26.0"
is-dom "^1.0.9"

react-is@^16.6.1:
version "16.7.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa"
integrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==

react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
Expand Down Expand Up @@ -9274,16 +9271,6 @@ react-proxy@^3.0.0-alpha.0:
dependencies:
lodash "^4.6.1"

react-reconciler@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.7.0.tgz#9614894103e5f138deeeb5eabaf3ee80eb1d026d"
integrity sha512-50JwZ3yNyMS8fchN+jjWEJOH3Oze7UmhxeoJLn2j6f3NjpfCRbcmih83XTWmzqtar/ivd5f7tvQhvvhism2fgg==
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"

react-split-pane@^0.1.84:
version "0.1.84"
resolved "https://registry.yarnpkg.com/react-split-pane/-/react-split-pane-0.1.84.tgz#b9c1499cbc40b09cf29953ee6f5ff1039d31906e"
Expand Down

0 comments on commit 9878ba7

Please sign in to comment.