komarovalexander / ka-table

Lightweight MIT React Table component with Sorting, Filtering, Grouping, Virtualization, Editing and many more

Home Page:http://ka-table.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Virtual scrolling breaks when showing new row

barucAlmaguer opened this issue · comments

commented

Hi, I just found an issue when triggering the "show new row" action on a virtualized table.

You can easily reproduce the case with the default virtualized example from ka-table docs:

TS Example

And triggering the action like this in the body of the Component:

// ADD THIS:
import { showNewRow } from 'ka-table/actionCreators'

const ManyRowsDemo: React.FC = () => {
  const [tableProps, changeTableProps] = useState(tablePropsInit);
  const dispatch: DispatchFunc = (action) => {
    changeTableProps((prevState: ITableProps) => kaReducer(prevState, action));
  };
  
  // ADD THIS:
  useEffect(() => {
    dispatch(showNewRow())
  }, [])

  return (
    <>
      <Table
        {...tableProps}
        dispatch={dispatch}
      />
    </>
  );
};

result:

Screen Shot 2022-09-23 at 18 04 51

I think the problem is that the virtualization code doesn't take into account that a "create new row" may be as the top row, and it should subtract it's height to the total "virtual row" it puts on top

Hi @barucAlmaguer thank you! I have reproduced that and will fix it this week

commented

Thanks!
I'll check it out 😄

@komarovalexander hi there, I'm helping @barucAlmaguer test this bug fix we stumbled upon a funny type error.

error TS2551: Property 'UpdateTreeGroupsExpanded ' does not exist on type 'Partial<Record<"ClearFocused" | "ClearSingleAction" | "CloseEditor" | "CloseRowEditors" | "DeleteRow" | "DeselectAllFilteredRows" | "DeselectAllRows" | "DeselectAllVisibleRows" | "DeselectRow" | ... 49 more ... | "Validate", (currentProps: ITableAllProps, params?: any) => void>>'. Did you mean 'UpdateTreeGroupsExpanded'?

The ActionType enum type has a UpdateTreeGroupsExpanded with the value being "UpdateTreeGroupsExpanded " with an empty space at the end.
Screen Shot 2022-10-03 at 16 37 32

Should I create a separate issue for this?