question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to dynamically position popper with caret offset?

See original GitHub issue

What is the expected behavior?

I am trying to build an auto suggestion or mention plugin using popper.

  1. Popper position should update on caret position updates e.g on textarea.
  2. If popper reaches view port boundary position should also update.

What went wrong?

Right i can update the position but i cannot do the view port boundary

    this.popper = new Popper(this.ref, this.popEl, {
      removeOnDestroy: true,
      modifiers: {
        preventOverflow: {
          enabled: true,
        },
        updatePosition: {
          enabled: true,
          order: 800,
          fn: data => {
            console.log(this.props.coords);

            return {
              ...data,
              styles: {
                ...data.styles,
                top: this.props.coords.top + 20,
                left: this.props.coords.left - 25,
              },
            };
          },
        },
        showPopper: {
          enabled: true,
          order: 850,
          fn: data => {
            return {
              ...data,
              styles: {
                ...data.styles,
                display: this.props.isOpen ? 'block' : 'none',
              },
            };
          },
        },
      },
    });

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
FezVrastacommented, Jan 11, 2018

I think the API is the same, you can adapt my code.

1reaction
FezVrastacommented, Jan 11, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to dynamically position popper with caret offset? #519
I am trying to build an auto suggestion or mention plugin using popper. Popper position should update on caret position updates e.g on...
Read more >
How to update the x/y position of a popper.js element?
appendChild(div) // get the marker position, this is the caret position top and left relative to the input const { offsetLeft: spanX, ...
Read more >
Everything I Know About Positioning Poppers (Tooltips ...
If the popper is not positioned relative to the viewport, we need to consider its offsetParent when measuring the reference element.
Read more >
Popper (v2.×)
Slower development cycle: When pure CSS is used to position popper elements, the lack of dynamic positioning means they must be carefully placed...
Read more >
How to Build a Dynamically Positioned Popover with Popper ...
Go to the blog post: https://www.elegantthemes.com/blog/di... The popper.js library is a powerful positioning engine for tooltips and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found