arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.25k stars 381 forks source link

Sketchbook view scrolls to selected sketch when another sketch is expanded/collapsed #2456

Open per1234 opened 3 months ago

per1234 commented 3 months ago

Describe the problem

Arduino IDE's "SKETCHBOOK" view shows a list of the sketches in the sketchbook folder. When sketches are located under a subfolder, or when the "Show files inside Sketches" preference is enabled, the folder tree can be expanded or collapsed by clicking the or ˅ icon to the left of the folder name in the view.

🐛 The view scrolls to make the currently selected item visible when the tree control icons are used.

sketchbook-scroll

To reproduce

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus. The "Preferences" dialog will open.
  2. Check the box next to "☐ Show files inside Sketches.
  3. Click the "OK" button. The "Preferences" dialog will close.
  4. Click the folder icon to open the "SKETCHBOOK" view in the side panel of the Arduino IDE window.
  5. If you don't already have enough sketches in your sketchbook to cause the "SKETCHBOOK" view to be scrollable, perform repeated File > Save As... operations until you have enough sketches.
  6. Click on the first item on the list. The item will be highlighted to indicate it is selected.
  7. Scroll to the bottom of the "SKETCHBOOK" view.
  8. Click the icon on the last sketch/folder on the list.

🐛 The view is scrolled up to the top, making the list item you were interacting with no longer visible.

Expected behavior

The

Arduino IDE version

aa9b10d68e6653b7f40ab920173c7964aaefbfa4

Operating system

Operating system version

11

Additional context

I arbitrarily chose to specify the use of the first and last list items in the demo, but the fault will occur with items at any position as long as the selected item is scrolled out of the visible view.

Originally reported by @dougp2 at https://forum.arduino.cc/t/sketch-folder-jumps-to-wrong-place-ide-2-3-2/1271809

Workaround

Click on the list item before clicking on its tree control icon.

Issue checklist

dougp2 commented 3 months ago

Thanks!