Unity-UI-Extensions / com.unity.uiextensions

https://unity-ui-extensions.github.io/
1.2k stars 129 forks source link

AutoCompleteComboBox Overlay object position drifting OnInputChange #361

Open SimonDarksideJ opened 2 years ago

SimonDarksideJ commented 2 years ago

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 commented 2 years ago

On 2020.12.09 12:15, @SimonDarksideJ commented: Could you provide replication steps or a small sample scene demonstrating the issue please, to help with diagnosis

SimonDarksideJ commented 2 years ago

On 2020.12.10 16:00, Gustavo Arcanjo commented: Sure, I’ve recorded the screen to better explain it: https://drive.google.com/file/d/1MYRle7nmsAUy9yNsrTxCcqYJnX8eB2sH/view?usp=sharing

The scene is as simple as a canvas with a AutoCompleteComboBox object added by right-clicking UI/Extensions/AutoComplete ComboBox, which was configured to have a few Available Options.

Pay attention to the Overlay Rect on the scene while typing something on the InputField during play.

SimonDarksideJ commented 2 years ago

On 2020.12.22 14:14, Gustavo Arcanjo commented: Hey, @{557058:da9b1be2-6172-44a5-a085-cae5d30eda9e} . Did you get the chance to watch my screen record and was it useful at all? Is it ok if I delete the video from my google drive?

SimonDarksideJ commented 2 years ago

On 2020.12.22 16:38, @SimonDarksideJ commented: I’ve downloaded it so you can safely delete it

SimonDarksideJ commented 2 years ago

On 2020.12.28 14:34, Gustavo Arcanjo commented: Thanks