atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
11.91k stars 518 forks source link

Tippy modifier doesn't update state #1017

Closed sabetAI closed 2 years ago

sabetAI commented 2 years ago

I'm using the following modifier to update the tippy instance's state:

modifiers: [
                {
                  name: "setMaxWidth",
                  phase: "write",
                  enabled: true,
                  fn: ({ state, instance }) => {
                    console.log(state);
                    const refWidth = state.rects.reference.width;
                    state.rects.popper.width = refWidth;
                    return state;
                  },
                },
              ],

What am I doing wrong?

atomiks commented 2 years ago

You're looking for the sameWidth modifier https://codesandbox.io/s/bitter-sky-pe3z9?file=/src/index.js