Hi Cozy! As discussed on the forum this is an attempt to allow users editing their transaction labels.
After considering adding a new comments field, I've leveraged the existing manualLabel which is used in recurring transactions.
Users can now:
edit their transaction labels in the transaction list (and search results). A new "pen" icon button turns the read-only cell into a text field (LabelField React component).
edit their transaction labels in the transaction modal, in a similar fashion.
see original labels, in case they changed some.
reset to the original label, with a dedicated "restore" button in the text field.
from the transaction modal, search for the manual or original label.
take advantage of keyboard navigation: when entering edition mode, the text field grabs focus. While editing, Enter will close and save, Escape will close without saving. All icon are buttons which are in the tab cycle.
🧪 How to test?
Here is a possible scenario:
Grab the code, locally, assuming you already have Cozy server set up and ready, with some fixtures install
in the transaction list, you'll have new pen icons
Click on a pen icon
the label is replaced with a text field with the original label as value, focus, and a close button in it
Change the value, and click on the close button/hit Escape key/click somewhere else
the manual value is saved, text field replaced with read-only value, and the original value is visible below.
Click on the transaction row
it opens the modal, with the manual and original labels, both followed by search icons
Click on the manual label pen icon
the manual field is editable, it has focus, close and restore icon
Hit Tab twice to focus on the restore icon, then Enter to trigger it
the manual label is discarded, text field replaced by read-only value. The original label row is gone, and the value in transaction list is also restored
There's plenty of other ways to test it, you can also try to search for manual labels.
❗ Notes to reviewers
This PR is draft, and I'd like to collect some feedback before adding automated tests.
In particular, I'd like to draw reviewers' attention on some tradeoffs:
the "pen" icon button are very small, which isn't convenient on mobile. However making them bigger makes the transaction row higher, which does not look good
the "close" button comes before "restore" button to make keyboard edition smoother.
the transaction is only saved when the text field is losing focus: no complicate throttle needed
I've styled the TextField so it looks like a Input field with "tiny" size, like in cozy-drive FilenameInput
Finally it worth calling out the great dev material you made to ease contributions. The setup isn't too complicated, and it's easy for a React dev to contribute.
I couldn't make HMR work (despite running my cozy-app-dev docker container with -e COZY_DISABLE_CSP=1), but it's not too bad.
✨ What's in there?
Hi Cozy! As discussed on the forum this is an attempt to allow users editing their transaction labels.
After considering adding a new comments field, I've leveraged the existing
manualLabel
which is used in recurring transactions.Users can now:
LabelField
React component).Enter
will close and save,Escape
will close without saving. All icon are buttons which are in the tab cycle.🧪 How to test?
Here is a possible scenario:
There's plenty of other ways to test it, you can also try to search for manual labels.
❗ Notes to reviewers
This PR is draft, and I'd like to collect some feedback before adding automated tests. In particular, I'd like to draw reviewers' attention on some tradeoffs:
the "pen" icon button are very small, which isn't convenient on mobile. However making them bigger makes the transaction row higher, which does not look good
the "close" button comes before "restore" button to make keyboard edition smoother.
the transaction is only saved when the text field is losing focus: no complicate throttle needed
I've styled the TextField so it looks like a Input field with "tiny" size, like in cozy-drive FilenameInput
Finally it worth calling out the great dev material you made to ease contributions. The setup isn't too complicated, and it's easy for a React dev to contribute. I couldn't make HMR work (despite running my cozy-app-dev docker container with
-e COZY_DISABLE_CSP=1
), but it's not too bad.