fjvallarino/monomer

Dropdown Widget sometimes selects element if clicked outside of list

Closed this issue · 3 comments

Here I modified dev-test-app to demonstrate weird behavior of dropdown widget: you can click outside of list and it will still select an element.

monomer-dropdown-bug.mp4

I somehow managed to fix this bug by wrapping selectListNode in a box widget

createDropdown wenv node newState = newNode where
  selected = currentValue wenv
  nodeStyle = _wnInfo node ^. L.style
  mainNode = makeMain selected
    & L.info . L.style .~ nodeStyle
  widgetId = node ^. L.info . L.widgetId
  selectListNode = makeSelectList wenv widgetData items makeRow config widgetId
  newWidget = makeDropdown widgetData items makeMain makeRow config newState
  newNode = node
    & L.widget .~ newWidget
    & L.children .~ Seq.fromList [mainNode, box selectListNode] -- bug fix

I think it works because SetOverlay widget request now applies to the box and not to the selectListNode which apparently "leaked" its items to the space around dropdown widget.

Again, I tested it only on Windows 10 and I don't know how it behaved before my fix and behaves with my fix on other systems.

Hi @Deltaspace0!

I just pushed an alternative solution. The one you provided works great, although in this case I'd rather have the issue fixed in selectList itself. I'm not happy about not being able to generate a failing unit test that this PR fixes (it passes in any case), but I'll leave it this way for the time being.

You can test the fix by modifying your stack.yaml to point to:

- git: https://github.com/fjvallarino/monomer.git
  commit: 649ad35d8f3f1262d3a9118030869cf368b9777c

Thanks for reporting!

I just merged the fix to main.

I'll close the issue now. If you feel something is missing, please re-open the issue or create a new one. Thanks!