floating-ui / react-popper

🍿⚛Official React library to use Popper, the positioning library
https://popper.js.org/react-popper/
MIT License
2.5k stars 226 forks source link

placement error!!! options.placement set 'top' but replace to 'bottom' #444

Closed acgblogs closed 2 years ago

acgblogs commented 2 years ago

<==== my code ====> const Example = () => { const [referenceElement, setReferenceElement] = React.useState(null); const [popperElement, setPopperElement] = React.useState(null); const { styles, attributes } = usePopper(referenceElement, popperElement, { placement: 'top' });

return (
  <>
    <button type="button" ref={setReferenceElement}>
      Reference
    </button>
    {ReactDOM.createPortal(
      <div
        ref={setPopperElement}
        style={styles.popper}
        {...attributes.popper}
      >
        Popper
      </div>,
      document.body
    )}
  </>
);

};

<==== popper render result ===> image

acgblogs commented 2 years ago

package version: "@popperjs/core": "^2.11.5", "react-popper": "^2.2.5"