react-laag icon indicating copy to clipboard operation
react-laag copied to clipboard

auto prop not acting as expected

Open rijk opened this issue 3 years ago • 0 comments

Take the following config:

useLayer({
  placement: 'right-center',
  possiblePlacements: [
    'right-center',
    'left-center',
    'bottom-center',
    'top-center',
  ],
  auto: false,
})

Expected result:

image

Actual result:

image

The possiblePlacements are only used when auto is set to true. This does not make sense to me, also when reading the definition of auto:

should we switch automatically to a placement that is more visible on the screen?

What I want to happen here is for useLayer to find the best position when opening the layer, but not reposition it afterwards. This way, there is no possibility to do that, because you'd always need to set auto to true.

Suggested change: make auto only control repositioning of an open layer, and initial placement always take possiblePlacements into account. If you'd not want any other positions to be selected, you just leave possiblePlacements empty right?

rijk avatar Dec 18 '20 12:12 rijk