Open lynneosmith opened 2 years ago
Hello @JinghuiMS @ononder Could you please provide an update to this issue? There has been no update in over 3 weeks. Thanks so much.
@ononder You expert, could you help answer this question? Thanks!
This, in theory, looks like working to set the selection to something new (setSelectedDataAsync), i.e. clearing existing selection and setting to something else. The primary scenario around this is to let the addins use and update whatever user has selected, such as grammer checking (first retrieving with getSelectedDataAsync and updating with setSelectedDataAsync). This is also mentioned in the documentation: Writes the specified data into the current selection.
So in my opinion the API is acting correctly.
If you have a shape selected and then run this code, which you gave me as a workaround for addTextBox not working correctly in https://github.com/OfficeDev/office-js/issues/2699, the selected shape will be deleted. This occurs only on web. On desktop, the shape is not deleted. Are you saying that in this code example, desktop is performing incorrectly?
If you are saying this is not a bug, how would you suggest that I unselect any currently selected shape before I use addTextBox or setSelectedDataAsync on web? I don't see any api that will allow me to do that. Currently, I am checking to see which slide is active, creating a new slide at the end of the presentation, then deleting that slide I just created, then setting the active slide back to the original one. By doing that, I am able to be sure that there are no selected shapes on the slide that is active when I make the addTextBox or setSelectedDataAsync call. This does cause a lot of screen flashing as the slide is added, deleted and then the users currently active slide is set back. Do you have a better suggestion as to how else I could be sure there is no active shape when I use this api? Our software is inserting content into the presentation. I can't assume the user doesn't have an active shape when I insert content. The ability to do this is absolutely crucial for shipping our product.
The other solution here for us would be to fix https://github.com/OfficeDev/office-js/issues/2699 so that on the web addTextBox would not require your workaround that is making a selected shape get deleted on web.
https://github.com/OfficeDev/office-js/issues/2699 appears to be working correctly for me now, so I am not trying to use this workaround anymore. However, I would like to note that this bug was reported to say that the code sample you gave me to use is deleting the currently selected shape. That is still the case. So, the description of this bug is still accurate. I appreciate the fix for 2699 and would also like a fix for https://github.com/OfficeDev/office-js/issues/3083 because then there would be a way to unselect currently selected shapes.
Provide required information needed to triage your issue
Running web powerpoint, you can recreate this issue following the steps I specify below using Scriptlab. You insert an image, have it selected, and then insert a textbox, using the workaround specified in https://github.com/OfficeDev/office-js/issues/2699 or inserting text with setSelectedDataAsync(). Either way, the image will be deleted when the text is inserted. On desktop, the text insertion does not cause the active image to be deleted.
Your Environment
Expected behavior
I expect the text to be added to the slide and the image to still be there.
Current behavior
If there is a selected shape on the slide, inserting a text shape with delete it when the text shape is added. The selected shape can be any shape. I reproduced it with both an image and another text shape.
Steps to reproduce
async function createTextBox() { await PowerPoint.run(async (context) => { var shapes = context.presentation.slides.getItemAt(0).shapes; var textbox = shapes.addTextBox("Hello!", { left: 100, top: 300, height: 300, width: 450 }); textbox.name = "Textbox";
}); }
Link to live example(s)
Provide additional details
Context
We are trying to insert multiple objects from a report into the slide. This problem is preventing us from being able to efficiently do this in the web environment. The only way I have found around this problem is to find a way to unselect any potentially selected shapes if I am going to insert a text shape. The only way I have found to do this is to insert a new slide to the end of the presentation and then delete it and then go back to the slide that was initially active to add the shape. This causes a lot of flashing and makes our addin function slowly and not optimally on the web environment.
Useful logs
none.
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.