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

Cannot insert image in web PowerPoint if another image is selected, but cannot unselect the image #4225

Open
nikhilatsap opened this issue Mar 6, 2024 · 2 comments
Assignees
Labels
Area: PowerPoint Issue related to PowerPoint add-ins Status: under investigation Issue is being investigated

Comments

@nikhilatsap
Copy link

Provide required information needed to triage your issue

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the Web
  • Host [Excel, Word, PowerPoint, etc.]: Powerpoint
  • Office version number: Office 365
  • Operating System: Windows
  • Browser (if using Office on the web): Chrome

Expected behavior

calling setSelectedDataAsync should not fail if the user has selected something; or there should be an alternative which inserts rather than attempting to change the selection as setSelectedDataAsync seems to be currently the only way to insert an image into PPT

calling slide.setSelectedShapes([]); should clear the selection

Current behavior

calling setSelectedDataAsync throws OSF.DDA.Error 2001

calling slide.setSelectedShapes([]); does nothing and appears to halt the PowerPoint.run callback, ie. no other statements after that appear to run, but there is no error message.

Steps to reproduce

insert a random image into the ppt slide (and leave it selected)
use setSelectedDataAsync to insert base64 image data with coercion type Image, ex.:
return new Promise((resolve, reject) => {
Office.context.document.setSelectedDataAsync(
base64Data,
{
coercionType: Office.CoercionType.Image,
},
async (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
reject(result.error.message);
}
return resolve(true);
},
);
});
image is not inserted, see in the console:
OSF.DDA.Error {
name: 'Data Write Error',
message: 'Cannot write to the current selection.',
code: 2001
}
this would not be an issue if we could programatically unselect, but for that:

insert a random image into the ppt slide (and leave it selected)
use code such as: (logging added for purposes of this issue)
const example = async (slideIndex) => {
await PowerPoint.run(async (context) => {
const slides = context.presentation.slides;
slides.load('items');
await context.sync();
const slide = slides.items[slideIndex]; // ex., 0 for a single-slide file

    const selected = context.presentation.getSelectedShapes();
    selected.load('items');
    await context.sync();
    console.log('selected', selected.items);

    slide.setSelectedShapes([]);
    await context.sync();

    console.log('before get selected');
    const selectedAfter = context.presentation.getSelectedShapes();
    console.log('after get selected');

    selectedAfter.load('items');
    console.log('after load, before sync');

    // nothing after here
    await context.sync();
    console.log('after sync');

    console.log('selectedAfter', selectedAfter.items);
});

console.log("outside of ppt run")

}
see that the first log reports the array of selected items (screenshot)
see that after setting the selection, it is not cleared, and loading the selection then seems to never resolve; ie., code after the ppt.run function does not run and no errors are logged or thrown
image
269110121-b1c6c581-c337-4bf5-b5f3-562b9cf4c86a

Context

Our addin allows users to insert a visual representation of a live file as an image into their PPT slide. If the backing file changes we would like to allow the users to update the image representation by selecting the image and clicking "update" from the task pane addin, which renders the latest version as an image, places itself where the old image was, and deletes the old image (since as far as I can tell we cannot update the existing image's contents).

Being unable to setSelectedDataAsync while an image is selected breaks this functionality since the image must be selected in the first place in order to have the option to update it appear in the task pane, which also shows other relevant information about the file).

We also believe this (the setSelectedDataAsync error) is a regression since I am somewhere between 75-99% sure that this update flow (ie. inserting an image while one is selected) was verified to be working in the browser before. The error is only thrown from Web, not desktop.

We could programatically deselect the image right before inserting (n.b., works in desktop, though is not needed there anyway), but using setSelectedShapes([]) does nothing in browser (see #3102, #3083).

Added the information about deselecting again in this issue since it provides context to why throwing an error on setSelectedDataAsync is not useful. Also highlighting that there are no errors logged when setting the selection to nothing fails, and it seems to cause the PowerPoint.run promise to never resolve.

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.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Mar 6, 2024
@AkhileshShah-MS AkhileshShah-MS added Area: PowerPoint Issue related to PowerPoint add-ins and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Mar 8, 2024
@AkhileshShah-MS
Copy link
Collaborator

Hi @nikhilatsap ! Thanks for reaching out to us.
Looping in @EsterBergen to help with the issue.
Thanks!

@AkhileshShah-MS AkhileshShah-MS added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Mar 8, 2024
@EsterBergen EsterBergen added Status: under investigation Issue is being investigated and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Mar 8, 2024
@hjyssg
Copy link

hjyssg commented Jun 20, 2024

Is there is any update on this bug? I am having the same problem in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: PowerPoint Issue related to PowerPoint add-ins Status: under investigation Issue is being investigated
Projects
None yet
Development

No branches or pull requests

4 participants