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.

setOptions() overrides previous modifiers

See original GitHub issue

CodeSandbox demo code

import { createPopper } from "@popperjs/core";

const button = document.querySelector("#button");
const tooltip = document.querySelector("#tooltip");

// Create a popper instance with some offset
let popper = createPopper(button, tooltip, {
  placement: "right",
  modifiers: [{ name: "offset", options: { offset: [0, 20] } }]
});

// Uncommenting the following will remove the offset
// popper.setOptions({
//   modifiers: [{ name: "eventListeners", enabled: true }]
// });

Steps to reproduce the problem

  1. Do createPopper() with an offset modifier
  2. Call setOptions() to enable/disable listeners
  3. The offset is now gone

What is the expected behavior?

I would expect existing modifiers to be unaffeted

What went wrong?

The offset is now gone

Any other comments?

My expectations come from the tutorial, where the behavior I expect is described. However pasting the tutorial’s full code into codepen, shows no offset.

This could be a documentation issue, since the actual tutorial code is different than the one displayed. But since I can’t find any clear documentation for setOptions(), I will assume it is a bug.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
FezVrastacommented, Sep 3, 2021

I added an option to pass a function to setOptions that will work very similarly to how React’s state setters work.

https://popper.js.org/docs/v2/constructors/#setoptions

1reaction
FezVrastacommented, Jun 17, 2021

I haven’t included an auto-merge functionality because it would increase a lot the size of the library, I’d rather left this to the consumer if they ever need it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

override java final methods via reflection or other means?
This will remove the 'final' modifier from the method. ... This should now use our new code when calling getDescription() which will include...
Read more >
SocketOptions (Java Platform SE 8 ) - Oracle Help Center
Subclasses of these should override the methods of this interface in order to support their own options. ... Modifier and Type, Field and...
Read more >
popper.js - Bountysource
In my app I am using custom elements to create a popout that uses popper for positioning. When I provide placement as "bottom",...
Read more >
MathLive - CortexJS
Calling setOptions () on a mathfield with options related to the keyboard will affect this shared virtual keyboard instance when the mathfield is...
Read more >
QWizard Class | Qt Widgets 6.4.1
These can be set using setOption() or setOptions(). For example, HaveHelpButton makes QWizard show a Help button along with the other wizard buttons....
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