92green / dataparcels

A library for editing data structures that works really well with React.
https://92green.github.io/dataparcels/
1 stars 0 forks source link

V2 - solve focus management #269

Open dxinteractive opened 4 years ago

dxinteractive commented 4 years ago

Really should be considered. Think about undo / redo stacks too.

Keeping track of focus

Probably requires sharedMeta to store whatever focus id is needed to be remembered.

Should it require the dev to explicitly say when they want focus shifted e.g. when push() is called?

Binding

Should it go:

.after(callback)

Make change methods return something, where a callback can be passed? how can this tell other rendered fields to do things?

dxinteractive commented 4 years ago

Could do the "push" thing with a modifier. Wouldnt work with history because its temporal:

things.toArray((thing) => {
    return <div key={thing.key}>
        <input {...thing.spread()} ref={(node) => thing.meta.isNew && node.focus()} />
    </div>;
})

parcel.pipe(isNew())

    .modifyDown(asNode(node => {
        return node.setMeta({
            isNew: !('isNew' in node.meta)
        });
    }))