OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
686 stars 95 forks source link

Shape tags are lost in PowerPoint Web with cut and paste #3784

Open lynneosmith opened 1 year ago

lynneosmith commented 1 year ago

On PowerPoint web, if you add a tag to a shape and then cut/copy the shape, the tag is no longer on the shape. On desktop PowerPoint, the tag is retained and is there on the pasted shape.

Your Environment

Expected behavior

I expect the tag of the shape to be in the pasted shape object, like it is in desktop PowerPoint.

Current behavior

If you put a tag on a shape and cut the shape and then paste the shape, it loses the tag. I expect it to retain it. I can reproduce this in Scriptlab.

Steps to reproduce

USE POWERPOINT WEB Step 1: Use Scriptlab - your "Work with tags" Sample Step 2: Add an empty slide as the first slide in the presentation. Step 3: Using the insert menu, add a rectangle shape to the empty first slide. Step 4: Go to your published "Work with tags" sample and view the code. Step 5: Replace the async function addPresentationTag() with the following code:

async function addPresentationTag() { await PowerPoint.run(async function(context) { const slide = context.presentation.slides.getItemAt(0); const shape = slide.shapes.getItemAt(0);

await context.sync();

console.log("here");

// const myShapeTag = shape.tags.getItem("MOUNTAIN");
// myShapeTag.load("key, value");

const myShapeTag = shape.tags.getItemOrNullObject("MOUNTAIN");
await context.sync();
if (myShapeTag.isNullObject) {
  console.log('null object');
}
myShapeTag.load("key, value");

await context.sync();

console.log("Found key " + JSON.stringify(myShapeTag.key) + " with value " + JSON.stringify(myShapeTag.value));

}); }

Step 6: Run your "Work with tags" - "Add a shape tag" sample and you will see the shape is tagged written to console. Step 7: Right click on the shape in the slide and select "Cut" from the context menu to remove the shape from the slide. Step 8: In the same slide, use Ctrl-V to paste the shape back in the slide. Step 9: Run the "Work with tags" - "Add presentation tag" sample that you replaced with the code in Step 5 above.

The console will display that you have a null object and the tag can no longer be found on a shape in the slide.

image

Provide additional details

None needed.

Context

This is a problem because our addin inserts and updates content in the slides. On PowerPoint desktop (and on Word and Excel), the user can cut/paste content to a different place and we can find it. We need consistency across products and ESPECIALLY between PowerPoint desktop and web products. We need to be able to update the content in the shapes and we can't do that if we can't find them because the tag was lost.

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Searion commented 1 year ago

Thans for reporting. I have tried it on web but cannot repro it. after cut and paste I can still get the tag like this. Could you please provide more information to help us identify the problem? image

lynneosmith commented 1 year ago

I have updated my steps to reproduce so that hopefully they are clear. Let me know if that helps you to be able to reproduce the problem. I tried them on a different developers machine and we were able to reproduce them there in his powerpoint web version as well. Thanks.

Searion commented 1 year ago

@lynneosmith I cannot repro it with the new steps. Could you please check the paste step. If your paste option is not “Use Destination theme” but "Picture", this tag will not be there.

lynneosmith commented 1 year ago

The build that I am running on Chrome is 16.0.17029.40515. Maybe you have a newer build? I tried it again multiple times. I right click on the slide and cut the image I have inserted. Then I tried pasting with CtrlV and the tag is not on the object. I tried again with clicking on the thumbnail IN the slide and the only paste option available is the first one, which is "use destination them" usually though the tip just says paste. I also tried it invoking the context menu by right clicking on the slide thumbnail. Same behavior. On desktop, after I cut an image, I have both "Use Destination theme" and "Picture" options available, but on WEB where I have this problem, I only have the first past option available. I also tried this on a coworkers machine and they ran the sample code and steps i gave above and they see the same issue that I do. Just a reminder that it works fine on desktop and only fails on web powerpoint.

EsterBergen commented 5 months ago

@lynneosmith - do you know if this issue is still occurring? Please let us know and we can investigate further. Thanks!

lynneosmith commented 5 months ago

Yes, I can still reproduce this behavior. It works correctly on Powerpoint desktop and does not work on Powerpoint web. I used the initial steps that I put in this ticket using ScriptLab. Thanks.