DWilliames / paddy-sketch-plugin

Automated padding, spacing and alignment for your Sketch layers
MIT License
2.17k stars 61 forks source link

[Bug] "Please select at least one layer to duplicate" - Modal keeps popping up #18

Closed alanonthegit closed 6 years ago

alanonthegit commented 6 years ago

When I have Paddy enabled, this popup comes up whenever I click around in different parts of Sketch files. DIsabling the Paddy plugin makes the message go away. Not sure if a conflict with Paddy or another plugin (no idea what makes this popup come up in the first place). Is this part of Paddy?

image

DWilliames commented 6 years ago

Interesting. That's definitely not Paddy — I don't have any alerts that mention anything about 'duplicating'.

To help you solve which Plugin may be causing this...

Can you try running this command in terminal

grep -nr 'one layer to duplicate*' ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins

And see what it spits out. That should search all files under the Sketch plugins folder, for anything that mentions "one layer to duplicate".

alanonthegit commented 6 years ago

@DWilliames I think I found the culprit in Invision Craft. I disabled the duplicate feature of Craft and the message went away. Also, I clicked on the button without selecting a layer and that was the message I received.

Unfortunately, I have to pick Craft over Paddy. I am using the DSM version, which may be a bit more of a beta release, but it's still really strange. I don't know why but when I have both Paddy and Craft enabled, I have this issue. I reinstalled Craft but that didn't fix it.

image

DWilliames commented 6 years ago

Interesting. Thanks for chasing that up @ar-stackrox. Maybe log that issue with Craft?

In the meantime, I'll close this issue, since Paddy isn't causing it.

nielsemann commented 6 years ago

I've got the same problem and already contacted InVision Team about this. Hopefully both plugins will work without a conflict soon…

padraigmckee commented 6 years ago

Same issue here. Thanks for reporting to InVision @nielsemann. Hope to have it fixed soon.

DWilliames commented 6 years ago

I'm getting quite a few reports of this now... I'm going to re-open this issue; and repoint all duplicates here.

I'm not sure how Paddy could be affected by Craft in this way — but I'll look into it.

DWilliames commented 6 years ago

So, it is definitely 'Duplicate' by Craft that is causing the issue. I've even found their line of code that is causing it.

  function m(e) {
      var t = e.document,
        o = e.command,
        a = e.selection,
        i = e.panel,
        m = a.count(),
        p = i.arguments(),
        b = i.identifier(),
        v = void 0;
      if (m > 1) v = f.action.groupSelection(t);
      else {
        if (1 !== m) return void(0, y.showAlert)("Please select at least one layer to duplicate.");
        v = a.firstObject()
      }
...

I still don't know why it is happening. My understanding was that the code would run synchronously; that is, no code of 'Duplicate' would run, until all the code of 'Paddy' had run.

However, when logging 'Paddy', only part of the code is run; then the alert from Craft appears, then a bit more of Paddy's code runs, then the alert appears again etc.

Does anyone have any tips or advice as to how I could stop this?

I'm assuming they must be doing some weird Key-value-observing or something in order for them to be running code asynchronously to Paddy.

DWilliames commented 6 years ago

I just pushed a release (v1.0.4) that should now fix this. 👍

I will close this issue for now, assuming that the fix is stable — if you find that it hasn't been fixed, then please re-open this issue.

Cheers!

alanonthegit commented 6 years ago

Hey @DWilliames thanks for the fix! It seems to work as expected.

However, I discovered something else, along the same lines. When I select a symbol and deselect it while running Paddy, I see the following message. Sometimes selecting more symbols will also increase the counter. Not sure where this conflict is coming from.

When I disable the plugin, the messages stop showing.

Edit: It only seems to happen on the Symbols page when selecting the symbol's artboard.

image