How to programmatically Scroll On Focus, in a LV_LIST using LVGL 8


According to the Documentation

Scroll on focus

Imagine that there a lot of objects in a group that are on scrollable object. Pressing the “Tab” button focuses the next object but it might be out of the visible area of the scrollable object. If the “scroll on focus” features is enabled LVGL will automatically scroll to the objects to bring the children into the view. The scrolling happens recursively therefore even nested scrollable object are handled properly. The object will be scrolled to the view even if it’s on a different page of a tabview.

I’m using a lv_list in LVGL 8.1 that remembers the last selected item.
When the list is displayed, I have now managed to leave the last selected item in a focused state | pressed state, but I still have to scroll down manually to see the item that was last selected (I hope you understand).

How do I enforce the ability to scroll to focussed item, If I focus an item programatically?

I have tried adding the scroll on focus flag to the button in the list, but it remains out of view.

My attempt

static void display_block_list(void)
  static char block_name[32];

  block_list = lv_list_create(blocks_cont);
  lv_obj_set_size(block_list, 320, 260); 
  lv_obj_align(block_list, LV_ALIGN_LEFT_MID, 0, 10);
  lv_obj_set_scrollbar_mode(block_list, LV_SCROLLBAR_MODE_AUTO);

  for (int i = 0; i < block_page_io_record->page_records; i++)
    sprintf(block_name, "%s", block_page[i].block);
    ESP_LOGW(TAG, "we have block: %s", block_name);
    list_btn[i] = lv_list_add_btn(block_list, NULL, block_name);
    itmp[i] = i;
    ESP_LOGW(TAG, "Param to be passed in as Index of Btn: %d", itmp[i]);
    lv_obj_add_event_cb(list_btn[i], select_block_event_cb, LV_EVENT_CLICKED, &itmp[i]);
    lv_obj_add_flag(list_btn[i], LV_OBJ_FLAG_SCROLL_ON_FOCUS);
  //Set the selected item in the list.
  ESP_LOGW(TAG,"Setting selected state of item: %d", block_page_io_record->page_record_selected_index);
  lv_obj_add_state(list_btn[block_page_io_record->page_record_selected_index], LV_STATE_PRESSED | LV_STATE_FOCUSED); //TODO LVGL check if actually works... v_list_focus_btn(block_list, list_btn[block_page_io_record->page_record_selected_index]);

Dou you find soluction for this issue? I have the same problem.