Skip to content

Editing/pending state reads stale synchronously — commitAllPending() inside state:change is a silent no-op #63

Description

@zvndev

Problem

useTable holds editing state as React-controlled state, so immediately after setPendingValue/fillRange — including inside a state:change event handler — table.getState().editing.pendingValues and hasPendingChanges() return the previous (often empty) snapshot. Calling commitAllPending() from the event handler therefore silently commits nothing. The values only become readable one render later.

Repro

table.on('state:change', () => {
  console.log(table.getState().editing.pendingValues) // {} right after fillRange
  table.commitAllPending() // no-op
})

Workaround

Bump a counter in the handler and run commitAllPending() in a useEffect keyed on it (post-flush).

Suggested fix

Have the imperative API read from a ref that's updated synchronously, or document that state reads inside event handlers are pre-flush and the effect-deferral pattern is required.

Versions: yable-react 0.10.4 / yable-core 0.9.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions