com.unity.uiextensions icon indicating copy to clipboard operation
com.unity.uiextensions copied to clipboard

AutoCompleteComboBox Overlay object position drifting OnInputChange

Open SimonDarksideJ opened this issue 2 years ago • 5 comments

Issue created by Gustavo Arcanjo as Bitbucket Issue #​361 on 2020.12.08 21:20. Whenever I type something in the input field, the Overlay object from the AutoCompleteComboBox component starts drifting and no longer works as expected (it should be used to call ToggleDropdownPanel and close it when clicking off).

Also, the overlay doesn’t work as intended for other objects below it in the canvas hierarchy, but adding a Canvas with a different Sort Order to the Overlay object in order to fix this Sort Order issue doesn’t make a difference in the behaviour of the drifting issue.

I’ve also tested with different Canvases, just to be sure.

The issue seems to be related with AutoCompleteComboBox.cs RedrawPanel method, more specifically lines 336-339.

  private void RedrawPanel()
  {
      float scrollbarWidth = _panelItems.Count > ItemsToDisplay ? _scrollBarWidth : 0f;//hide the scrollbar if there's not enough items
      _scrollBarRT.gameObject.SetActive(_panelItems.Count > ItemsToDisplay);
      if (!_hasDrawnOnce || _rectTransform.sizeDelta != _inputRT.sizeDelta)
      {
          _hasDrawnOnce = true;
          _inputRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _rectTransform.sizeDelta.x);
          _inputRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _rectTransform.sizeDelta.y);

          _scrollPanelRT.SetParent(transform, true);//break the scroll panel from the overlay
          _scrollPanelRT.anchoredPosition = new Vector2(0, -_rectTransform.sizeDelta.y); //anchor it to the bottom of the button

          //make the overlay fill the screen
          _overlayRT.SetParent(_canvas.transform, false); //attach it to top level object
          _overlayRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _canvasRT.sizeDelta.x);
          _overlayRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _canvasRT.sizeDelta.y);
      .
      .
      .

SimonDarksideJ avatar Apr 26 '22 07:04 SimonDarksideJ