humanmade / authorship

A modern approach to author attribution in WordPress.
GNU General Public License v3.0
68 stars 7 forks source link

#37 - Persist state #45

Closed johnbillion closed 3 years ago

johnbillion commented 3 years ago

See #37

This addresses the problem of the component being unmounted when switching between views in the block editor. Its state is lost if you change the attributed authors but haven't saved the post.

This change switches to storing an array of Option objects in the state and only using the IDs for storing in the post attribute. This unfortunately means a REST API lookup to fetch the user objects.

This fixes the immediate problem, but I'll follow up with a separate issue to see if we can use the _embed response from the post object when the editing screen first loads to at least avoid the initial REST API request.