[Bug] Changing layer name, changes layer to visible

Finally, after a few hours of writing plugin almost from scratch, but now using example @kerrishotts provided as a base, it’s done. And now it works so much better and more smoothly - state keeps preserved, groups keep collapsed if they were collapsed. Applied same example for layer ordering. Also now have normal history states. Just amazing how one property can change everything.

But I’ve encountered some Ps bugs(?). Tested without a plugin, and it’s the same.

  • If empty transparent layer is selected and you create new adjustment layer, it overwrites tat empty layer. Bug? Feature?
  • If you have a layer group with a color and a layer (or a few) below that group and you want to make a group of the immediate bellow layer(s), this new group takes color of the group above (also all inner layers get that same color). Definitely a bug.

Thank you all so much for the help and patience with me :slight_smile:

P. S. I’m not accepting @kerrishotts answer as a solution, because this is just a workaround to the initial issue with DOM

It’s not a bug, it’s a feature!

(for real)

What is layer ID then? Does it keep old layer ID or the new is used?

Didn’t check specifically, but my plugin now is based completely on IDs and it fell apart when empty layer, that my plugin watches, was replaced with that new one

That is exactly the reason why I ask :smiley:

Converting an empty layer to a text or adjustment etc assigns a new layerID.

If your script needs to target a layer that you created inside the script you have these options:

  • reference it by index (might need to count all new layers you add)
  • give it a name and reference it by this one (i think this is the best option - if you add layers in your script, why not give them a unique name. You can always set it to something else at the end)
  • do all operations on it while its still the target layer
  • let the batchPlay call finish and get the ID from it’s returned Descriptors (or via getter) → Problem: You’ll have more than one history step
  • navigate through the layer tree with next & previous layer refs, if you know the offset to the currently selected layer