Related: #14512
The data module includes a persistence plugin which can be used by data stores to persist state values to browser storage.
https://github.com/WordPress/gutenberg/tree/master/packages/data/src/plugins/persistence
In the block editor, this is used in a few stores to persist preferences (e.g. toolbar placement, "new user experience" tips, etc).
Due to the transient nature of browser storage, this persistence is not as sticky as it is expected to be, including: switching browsers (unique storage between browsers), or using private browsing tabs (storage cleared between sessions), or the same user across a network of sites (storage unique by domain).
Proposal:
Preferences should be persisted as user meta. Given the WordPress-agnostic nature of the @wordpress/data module, this should be implemented in such a way that another environment could substitute their own (assumed asynchronous) persistence mechanism.
Specific details:
Related: #14512
The data module includes a
persistenceplugin which can be used by data stores to persist state values to browser storage.https://github.com/WordPress/gutenberg/tree/master/packages/data/src/plugins/persistence
In the block editor, this is used in a few stores to persist preferences (e.g. toolbar placement, "new user experience" tips, etc).
Due to the transient nature of browser storage, this persistence is not as sticky as it is expected to be, including: switching browsers (unique storage between browsers), or using private browsing tabs (storage cleared between sessions), or the same user across a network of sites (storage unique by domain).
Proposal:
Preferences should be persisted as user meta. Given the WordPress-agnostic nature of the
@wordpress/datamodule, this should be implemented in such a way that another environment could substitute their own (assumed asynchronous) persistence mechanism.Specific details:
Add a new option(Edit: This should not be necessary, see Persist user's editor preferences to database rather than local storage #15105 (comment))onChangeto the plugin interfaceonChangeshould communicate with the users REST endpoint, updating using themetafieldshow_in_rest)