Hierarchical Listbox Scroll Position - Bug or Intended Behavior?

When using a hierarchical listbox, if you:

  1. Add enough rows so that they are all visible in the listbox
  2. Expand a row
  3. Scroll down so that some of the top rows are no longer visible
  4. Collapse the row

You are now in a situation where the listbox could be showing all of the items, but the first rows are still scrolled off the top of the listbox.

Scrolling just once in this situation causes the listbox to correct itself by scrolling all the way to the top, but shouldn’t this be done automatically when the row is collapsed?

Screenshot 2024-07-16 at 2.28.56 PM
Screenshot 2024-07-16 at 2.29.01 PM

Screenshot 2024-07-16 at 2.29.05 PM

If you reproduce this in the Finder, it will scroll to the top to make sure that everything is visible since it should all fit in the window.

Bug or intended behavior?

The same behaviour applies when you remove rows. Say you have more rows than the listbox can show, you move down to the last visible rows and you start deleting rows (e.g. from the KeyDown event). You’ll see the rows after the one being removed moving up one row and the listbox won’t adjust its scrolling. If you remove all the visible rows, the listbox can appear to have no more rows (or just a partial row at the top).
Not telling whether it’s the intended behaviour, but I guess it’s one of these areas where it’s up to the programmer to take care of this.

It has always behaved that way. You could file a feature request to change it if you want to. Remember, Listbox is a custom Xojo control not a native one. The behavior won’t always match Finder 1-to-1.