Modified slug gets updated once again when record form is reopened
benosman opened this issue · 2 comments
Hey @dimitrov-adrian
Thanks for creating this extension, it looks to be very handy!
I am testing it out on an instance and I noticed a behaviour which I think is a bug, or at least could be improved, here are the steps to reproduce:
- Add slug field & interface to collection, set template as another field.
- Create / edit a record with a custom url, when editing for the first time the interface behaves correctly, after editing, the slug is no longer auto-generated.
- Save the record with edited slug
- Reopen the record for editing.
- Slug displays the wand button (auto-generate), so
haveChange
is true. - Any changes to the field set as template immediately triggers updating the url, so the previous changes are lost.
I think that changes should be persistent when the form is reopened for editing.
I thought it may be a simple fix in setup()
to instantiate isTouched
based on haveChange
but that turned out to only work when the form is loaded for the first time (e.g. a full page refresh). When following a link from inside the admin app, props.value
is null
in setup()
and gets populated later on.
I have a working version, but I haven't created a pull request as there is likely a better way to accomplish this:
benosman@1948e03
Note: my fork is modified to work on a slightly outdated version of directus, but the actual vue component was the same as your v1.0.0
Yes, I agree it might be confusing in some cases. I also tried your fix, but isn't it in conflicts with the "On update" mode? I am thinking with this, it trying to disable it when the value is set and differs from auto generated one.