Skip to content

table.value.rootRef? #5230

@ValentinOsvaldo

Description

@ValentinOsvaldo

Context

I'm working with @nuxt/ui@4.0.1 and I encountered an issue

In the official documentation

https://ui.nuxt.com/docs/components/table#with-infinite-scroll

When implementing infinite scroll pagination, the documentation provides this example:

const table = useTemplateRef('table')

onMounted(() => {
  useInfiniteScroll(
    table.value?.rootRef,
    () => {
      skip.value += 10
    },
    {
      distance: 200,
      canLoadMore: () => {
        return status.value !== 'pending'
      }
    }
  )
})

However, the table reference (table) only exposes:

tableRef: Ref<HTMLTableElement | null, HTMLTableElement | null>;
tableApi: Table<Scrap>;

The rootRef property does not exist.

The solution

Use parentElement from tableRef

onMounted(() => {
  useInfiniteScroll(
    table.value?.tableRef?.parentElement,
    () => {
      emit('fetchNextPage');
    },
    {
      distance: 200,
      canLoadMore: () => !loading,
    }
  );
});

My question

Is the documentation outdated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedv3#1289

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions