diff --git a/package.json b/package.json
index bacfe1e9c3..43e745d67e 100644
--- a/package.json
+++ b/package.json
@@ -133,6 +133,7 @@
},
"dependencies": {
"@babel/runtime": "^7.3.4",
+ "@popperjs/core": "^2.4.4",
"body-scroll-lock": "^2.5.8",
"classnames": "^2.2.5",
"date-fns": "^1.28.5",
@@ -143,6 +144,7 @@
"react-hot-loader": "^4.3.11",
"react-markdown": "^4.0.8",
"react-pdf": "^4.0.5",
+ "react-popper": "^2.2.3",
"react-select": "2.2.0",
"react-swipeable-views": "0.13.3"
},
diff --git a/react/ActionMenu/Readme.md b/react/ActionMenu/Readme.md
index f7fe9993a3..cae813632c 100644
--- a/react/ActionMenu/Readme.md
+++ b/react/ActionMenu/Readme.md
@@ -91,9 +91,10 @@ const hideMenu = () => setState({ menuDisplayed: false });
```
-### Placement
+### Placement on desktop
-The `placement` and `anchorElRef` prop can be used to control the placement of the menu on desktop. `anchorElRef` should be a ref to a DOM element and not a react component.
+You can pass a reference to a custom DOM element through the `anchorElRef` prop to attach the menu to that element.
+We use [popper.js](https://popper.js.org/docs/v2/) under the hood. You can use the `popperOptions` prop to pass options to the popper.js instance. This lets you control things like placement relative to the anchor, positioning strategies and more — refer to the popper doc for all the details.
```
import ActionMenu, { ActionMenuItem } from 'cozy-ui/transpiled/react/ActionMenu';
@@ -114,112 +115,9 @@ const anchorRef = React.createRef();
{state.menuDisplayed &&
}>Item 1
}
```
-
-### ActionMenu inside custom fixed elements
-
-The ActionMenu component is rendered at the root of the DOM tree using a [Portal](https://reactjs.org/docs/portals.html) and a fixed z-index. Since Modals for example have a higher z-index than ActionMenus, an ActionMenu _inside_ a Modal would be displayed behind it, instead of over it. To fix this problem, the Popper instance
-is given a reference to the Modal DOM node for its `container` option via a special
-React context.
-
-Any z-indexed element that will display action menus should use this technique to
-provide a ref to a node inside this stacking context (CSS context, not React
-context).
-
-```
-import { useRef, useState, useCallback } from 'react'
-import PopperContainerContext from '../PopperContainerContext'
-import ActionMenu, { ActionMenuItem, ActionMenuHeader } from './index';
-import Icon from '../Icon';
-
-const MyActionMenu = ({ anchorRef, buttonRef, onClose }) => {
- return
- }>Item 1
-
-}
-
-const MyFixedElement = () => {
- const ref = useRef()
- const [shown, setShown] = useState(isTesting())
- const buttonRef = useRef()
- const show = useCallback(() => setShown(true), [setShown])
- const hide = useCallback(() => setShown(false), [setShown])
- return
-
- {/** The popper ref is on a sibling node and not on a parent so that its ref
- gets filled in before we render the content of the modal. When the ref
- is on a parent of the modal, the ref is not filled yet when we render
- the content of the modal */}
-
-