dimitrov-adrian/directus-extension-wpslug-interface

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:

  1. Add slug field & interface to collection, set template as another field.
  2. 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.
  3. Save the record with edited slug
  4. Reopen the record for editing.
  5. Slug displays the wand button (auto-generate), so haveChange is true.
  6. 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.

I am closing this one, as far as I understands, it's completely handled by the on update and on create options from the interface setup

image