@hig/flyout
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -1,2 +0,2 @@ | ||
import React, { useState, useEffect, useRef } from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -1248,22 +1248,6 @@ import { createCustomClassNames, combineEventHandlers } from '@hig/utils'; | ||
const [open, setOpen] = useState(props.defaultOpen); | ||
const [actionRect, setActionRect] = useState(undefined); | ||
const [panelRect, setPanelRect] = useState(undefined); | ||
const [pointerRect, setPointerRect] = useState(undefined); | ||
const actionRef = useRef(); | ||
const panelRef = useRef(); | ||
const pointerRef = useRef(); | ||
const wrapperRef = useRef(); | ||
useEffect(() => { | ||
if (actionRef.current) { | ||
setActionRect(actionRef.current.getBoundingClientRect()); | ||
} | ||
if (panelRef.current) { | ||
setPanelRect(panelRef.current.getBoundingClientRect()); | ||
} | ||
if (pointerRef.current) { | ||
setPointerRect(pointerRef.current.getBoundingClientRect()); | ||
} | ||
}, [actionRef.current, panelRef.current, pointerRef.current]); | ||
const [actionRef, setActionRef] = useState(undefined); | ||
const [panelRef, setPanelRef] = useState(undefined); | ||
const [pointerRef, setPointerRef] = useState(undefined); | ||
const [wrapperRef, setWrapperRef] = useState(undefined); | ||
/** | ||
@@ -1280,6 +1264,9 @@ * @returns {Coordinates} | ||
if (!actionRect || !panelRect || !pointerRect || typeof window === "undefined") { | ||
if (!actionRef || !panelRef || !pointerRef || typeof window === "undefined") { | ||
return DEFAULT_COORDINATES; | ||
} | ||
const actionRect = actionRef.getBoundingClientRect(); | ||
const panelRect = panelRef.getBoundingClientRect(); | ||
const pointerRect = pointerRef.getBoundingClientRect(); | ||
const viewportRect = window.document.documentElement.getBoundingClientRect(); | ||
@@ -1348,3 +1335,3 @@ const coordinates = getCoordinates({ | ||
const refAction = actionRefParam => { | ||
actionRef.current = actionRefParam; | ||
setActionRef(actionRefParam); | ||
}; | ||
@@ -1357,3 +1344,3 @@ /** | ||
const refPointer = pointerRefParam => { | ||
pointerRef.current = pointerRefParam; | ||
setPointerRef(pointerRefParam); | ||
}; | ||
@@ -1366,3 +1353,3 @@ /** | ||
const refPanel = panelRefParam => { | ||
panelRef.current = panelRefParam; | ||
setPanelRef(panelRefParam); | ||
}; | ||
@@ -1375,3 +1362,3 @@ /** | ||
const refWrapper = wrapperRefParam => { | ||
wrapperRef.current = wrapperRefParam; | ||
setWrapperRef(wrapperRefParam); | ||
}; | ||
@@ -1409,3 +1396,3 @@ | ||
} = props; | ||
const flyoutClicked = event.target === wrapperRef || wrapperRef.current.contains(event.target); | ||
const flyoutClicked = event.target === wrapperRef || wrapperRef.contains(event.target); | ||
if (flyoutClicked || !isOpen()) return; | ||
@@ -1412,0 +1399,0 @@ if (onClickOutside) onClickOutside(event); |
@@ -1258,22 +1258,6 @@ 'use strict'; | ||
const [open, setOpen] = React.useState(props.defaultOpen); | ||
const [actionRect, setActionRect] = React.useState(undefined); | ||
const [panelRect, setPanelRect] = React.useState(undefined); | ||
const [pointerRect, setPointerRect] = React.useState(undefined); | ||
const actionRef = React.useRef(); | ||
const panelRef = React.useRef(); | ||
const pointerRef = React.useRef(); | ||
const wrapperRef = React.useRef(); | ||
React.useEffect(() => { | ||
if (actionRef.current) { | ||
setActionRect(actionRef.current.getBoundingClientRect()); | ||
} | ||
if (panelRef.current) { | ||
setPanelRect(panelRef.current.getBoundingClientRect()); | ||
} | ||
if (pointerRef.current) { | ||
setPointerRect(pointerRef.current.getBoundingClientRect()); | ||
} | ||
}, [actionRef.current, panelRef.current, pointerRef.current]); | ||
const [actionRef, setActionRef] = React.useState(undefined); | ||
const [panelRef, setPanelRef] = React.useState(undefined); | ||
const [pointerRef, setPointerRef] = React.useState(undefined); | ||
const [wrapperRef, setWrapperRef] = React.useState(undefined); | ||
/** | ||
@@ -1290,6 +1274,9 @@ * @returns {Coordinates} | ||
if (!actionRect || !panelRect || !pointerRect || typeof window === "undefined") { | ||
if (!actionRef || !panelRef || !pointerRef || typeof window === "undefined") { | ||
return DEFAULT_COORDINATES; | ||
} | ||
const actionRect = actionRef.getBoundingClientRect(); | ||
const panelRect = panelRef.getBoundingClientRect(); | ||
const pointerRect = pointerRef.getBoundingClientRect(); | ||
const viewportRect = window.document.documentElement.getBoundingClientRect(); | ||
@@ -1358,3 +1345,3 @@ const coordinates = getCoordinates({ | ||
const refAction = actionRefParam => { | ||
actionRef.current = actionRefParam; | ||
setActionRef(actionRefParam); | ||
}; | ||
@@ -1367,3 +1354,3 @@ /** | ||
const refPointer = pointerRefParam => { | ||
pointerRef.current = pointerRefParam; | ||
setPointerRef(pointerRefParam); | ||
}; | ||
@@ -1376,3 +1363,3 @@ /** | ||
const refPanel = panelRefParam => { | ||
panelRef.current = panelRefParam; | ||
setPanelRef(panelRefParam); | ||
}; | ||
@@ -1385,3 +1372,3 @@ /** | ||
const refWrapper = wrapperRefParam => { | ||
wrapperRef.current = wrapperRefParam; | ||
setWrapperRef(wrapperRefParam); | ||
}; | ||
@@ -1419,3 +1406,3 @@ | ||
} = props; | ||
const flyoutClicked = event.target === wrapperRef || wrapperRef.current.contains(event.target); | ||
const flyoutClicked = event.target === wrapperRef || wrapperRef.contains(event.target); | ||
if (flyoutClicked || !isOpen()) return; | ||
@@ -1422,0 +1409,0 @@ if (onClickOutside) onClickOutside(event); |
@@ -0,1 +1,8 @@ | ||
# [@hig/flyout-v2.1.3](https://github.com/Autodesk/hig/compare/@hig/flyout@2.1.2...@hig/flyout@2.1.3) (2022-04-20) | ||
### Bug Fixes | ||
* Updating the Flyout refs in the callbacks sent as props to the child component ([0791e86](https://github.com/Autodesk/hig/commit/0791e86)) | ||
# [@hig/flyout-v2.1.2](https://github.com/Autodesk/hig/compare/@hig/flyout@2.1.1...@hig/flyout@2.1.2) (2022-04-14) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/flyout", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "HIG Flyout", | ||
@@ -5,0 +5,0 @@ "author": "Autodesk Inc.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70
112682
3368