aboutsummaryrefslogtreecommitdiffstats
path: root/docs/form_persisting_architecture.md
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-09-13 06:25:36 +0800
committerkumavis <aaron@kumavis.me>2016-09-13 06:25:36 +0800
commit850b6d144092291bb80ad998d3f8177da9c98c13 (patch)
tree94666fa470c77971c56217e762fece18bf2e3edf /docs/form_persisting_architecture.md
parent2f289fb115f0b09ab7852b4c89b3c39c5bf6ec4e (diff)
parentb8f75e387a91135b870c9f268977445c8e0877a4 (diff)
downloadtangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar.gz
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar.bz2
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar.lz
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar.xz
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.tar.zst
tangerine-wallet-browser-850b6d144092291bb80ad998d3f8177da9c98c13.zip
Merge branch 'master' of github.com:MetaMask/metamask-plugin into library
Diffstat (limited to 'docs/form_persisting_architecture.md')
-rw-r--r--docs/form_persisting_architecture.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/form_persisting_architecture.md b/docs/form_persisting_architecture.md
new file mode 100644
index 000000000..e2d766ccc
--- /dev/null
+++ b/docs/form_persisting_architecture.md
@@ -0,0 +1,28 @@
+# Form Persisting Architecture
+
+Since:
+ - The popup is torn down completely on every click outside of it.
+ - We have forms with multiple fields (like passwords & seed phrases) that might encourage a user to leave our panel to refer to a password manager.
+
+ We cause user friction when we lose the contents of certain forms.
+
+ This calls for an architecture of a form component that can completely persist its values to LocalStorage on every relevant change, and restore those values on reopening.
+
+ To achieve this, we have defined a class, a subclass of `React.Component`, called `PersistentForm`, and it's stored at `ui/lib/persistent-form.js`.
+
+To use this class, simply take your form component (the component that renders `input`, `select`, or `textarea` elements), and make it subclass from `PersistentForm` instead of `React.Component`.
+
+You can see an example of this in use in `ui/app/first-time/restore-vault.js`.
+
+Additionally, any field whose value should be persisted, should have a `persistentFormId` attribute, which needs to be assigned under a `dataset` key on the main `attributes` hash. For example:
+
+```javascript
+ return h('textarea.twelve-word-phrase.letter-spacey', {
+ dataset: {
+ persistentFormId: 'wallet-seed',
+ },
+ })
+```
+
+That's it! This field should be persisted to `localStorage` on each `keyUp`, those values should be restored on view load, and the cached values should be cleared when navigating deliberately away from the form.
+