acf-extended / ACF-Extended

🚀 All-in-one enhancement suite that improves WordPress & Advanced Custom Fields
https://www.acf-extended.com
238 stars 27 forks source link

Copy Layout/Layouts doesn't work if you have a lot of fields #124

Closed TobyOsborne closed 4 months ago

TobyOsborne commented 5 months ago

Describe the bug

On Chrome when you have a post with a lot of fields/layouts and try to copy the layout, it fails to copy, and falls back to the alert window copy method; But then when you paste it, it breaks the layout.

The reason is that Chrome defaults an inputs maxlength to 524288. So, anything with more characters than that doesn't get added making the json string break. I believe the prompt window also has the same limitation.

Though I do recognise that 524288 is a lot (Honestly, clones of clones may not have been the best idea).

Would it be possible to implement the navigator clipboard API, with a fallback to the current method? By adding this here and here

const copied = navigator.clipboard.writeText(data).then(() => {
      alert("Layout has been transferred to your clipboard");
      return true;
}).catch(()=>{ /*Fallback code here*/});

Issue video: https://share.thedigitalduck.co.uk/v/Kl1RGy Fix with: https://share.thedigitalduck.co.uk/v/23DbTS

acf-extended commented 4 months ago

Hello,

Thanks the feedback!

I never reached this edge-case in the past. Your Flexible Content is probably very complex! Thanks for the details and suggested fix, it's a nice idea. I'll implement it in the next patch.

Have a nice day! Regards.

acf-extended commented 4 months ago

Hello,

Just a heads up to let you know that the latest 0.9.0.1 version now use the navigator.clipboard API.

Thanks again for the suggestion!

Have a nice day!

Regards.

TobyOsborne commented 4 months ago

Awesome, 👍 Thanks a bundle for adding that in and doing it so quickly too.

Have a fantastic day, and weekend.