Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Matrix block gets cloned #15

Open
architchandra opened this issue Jan 18, 2021 · 8 comments
Open

Wrong Matrix block gets cloned #15

architchandra opened this issue Jan 18, 2021 · 8 comments

Comments

@architchandra
Copy link

Description
In a Matrix field, the wrong block (and of the wrong type) gets cloned while the entry is in an unsaved state. It was likely the block on which the clone functionality was run previously. Starts working properly on saving the entry but happens again after a few blocks are clones without saving the entry. I was able to see this most commonly on blocks that contained Table fields, but that might be a conincidence.

Steps to reproduce

  1. Clone different blocks randomly and wait for a bit (perhaps for a draft to get auto-saved)
  2. Continue cloning different blocks till you notice the issue 😛 (do not save the entry or refresh the page)

Additional info

  • Plugin version: 1.1.11
  • Craft version: 3.4.30
  • Multi-site: No

Additional context
A few Super Table fields exist in the system but not in the Matrix field in which I observed the issue.

@architchandra
Copy link
Author

Also encountered errors of the type mentioned in #13 and #14, where a block just wasn't getting cloned at all and the action was failing silently.

From the smith.log file:

2021-01-18 20:16:31 [-][1][-][error][smith] Unable to find block for new1.
2021-01-18 20:16:31 [-][1][-][error][smith] {"type":"timeline","enabled":"1","fields":{"heading":"Early Admission","events":[{"col1":{"date":"05/12/2019","timezone":"Asia/Kolkata"},"col4":{"date":"21/01/2021","timezone":"Asia/Kolkata"},"col2":"dmy","col3":"Last Date of Application"},{"col1":{"date":"04/01/2020","timezone":"Asia/Kolkata"},"col4":{"date":"23/01/2021","timezone":"Asia/Kolkata"},"col2":"my","col3":"Personal Interview"},{"col1":{"date":"01/02/2020","timezone":"Asia/Kolkata"},"col4":{"date":"","timezone":"Asia/Kolkata"},"col2":"my","col3":"Announcement of Selection"}]},"blockId":"new1"}

and

2021-01-18 20:06:05 [-][1][-][error][smith] Unable to find block for new2.
2021-01-18 20:06:05 [-][1][-][error][smith] {"type":"table","enabled":"1","fields":{"table":{"columns":{"colcol0":{"heading":"Item","width":"50%","align":"left"},"colcol1":{"heading":"Amount","width":"20%","align":"left"},"colcol2":{"heading":"Deadline","width":"30%","align":"left"}},"rows":{"rowrow0":{"colcol0":"First semester","colcol1":"30000","colcol2":"30 Nov 2020"},"rowrow1":{"colcol0":"Second semester","colcol1":"35000","colcol2":"3 Jan 2020"}}}},"blockId":"new2"}

@architchandra
Copy link
Author

Both kinds of issues seem a bit random, though, and are reproducible only after multiple trial-and-error attempts.

@engram-design
Copy link
Member

Should be fixed in 1.1.12, but let me know!

@architchandra
Copy link
Author

Thanks a lot for the quick turnaround, but it looks like the problem of blocks not turning up when cloned still exists...sort of.

I cloned a block containing a table and new block didn't show up. But I tried again and it did the second time. Still feels a bit random and not reliable. I Will test more and share my findings.

Also, when a block fails to clone, the browser scrolls to either the top or bottom of the page. (Probably because the element to scroll to doesn't exist?)

@engram-design engram-design reopened this Jan 19, 2021
@engram-design
Copy link
Member

Hmmm, I'll also try my best to replicate it again!

@architchandra
Copy link
Author

architchandra commented Jan 19, 2021

Is there a chance that my data has become corrupt? Any changes that I should make (like re-save entries)? I'll also try on a new entry.

@architchandra
Copy link
Author

Hi @engram-design

I had updated the plugin to 1.1.14 but am still seeing the issue where the wrong block is sometimes cloned (usually the block that I had cloned earlier).

I'm also seeing another issue in one of the entries where the Clone button stops working altogether (nothing happens when I click it, even the dropdown with the Copy, Paste and Clone options stays open as if the associated click (or equivalent) event didn't fire).

In the above case, I also noticed an error in the console:

Uncaught TypeError: t.blocks.filter is not a function
    at s.constructor.filterBlocks (smith.js:291)
    at smith.js:317
    at Array.forEach (<anonymous>)
    at s.constructor.filterBlocks (smith.js:307)
    at smith.js:317
    at Array.forEach (<anonymous>)
    at s.constructor.filterBlocks (smith.js:307)
    at smith.js:317
    at Array.forEach (<anonymous>)
    at s.constructor.filterBlocks (smith.js:307)

It would be great if you can help with this. Thanks!

Version information:

Craft CMS: 3.7.7
Smith: 1.1.14
Browser: MS Edge for Mac Version 92.0.902.73 (Official build) (arm64)
OS: MacOS Big Sur 11.3.1 (20E241)

(Attaching images to share more information on the system and plugins).
Screenshot 2021-08-20 at 5 53 43 PM
Screenshot 2021-08-20 at 5 54 14 PM
Screenshot 2021-08-20 at 5 54 26 PM

@engram-design
Copy link
Member

Really struggling to replicate this one, particularly the error being thrown. Wondering if you might be able to share a video of you replicating the issue? If there are any nested fields (or if the Matrix is nested), as well as trying a reduced test case (test an entry with little to no blocks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants