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
677 stars 95 forks source link

ChartsCollection.onDeactivated event fires wrongly when shift-click a second chart - fix or document? #4370

Open NickRedwood opened 6 months ago

NickRedwood commented 6 months ago

Article URL On what page did you find the problem? https://learn.microsoft.com/en-us/javascript/api/excel/excel.chartcollection?view=excel-js-preview#excel-excel-chartcollection-ondeactivated-member

Describe the problem You have two charts on an Excel sheet and you add onActivated and onDeactivated methods to either the individual Charts or the ChartCollection, as in the linked example. If you click one chart then onActivated fires. If you then shift-click the second chart, onDeactivated fires on the first chart, even though it is still active.

I recently realised the web version of Excel (which I rarely use) does not allow multiple selection of charts or shapes, which I guess is the source of this problem. In desktop Excel though the current behaviour is not right. If it can't be fixed, a note in the documentation could be added.

The overall context is I'm trying to create an add-in to apply bulk formatting to charts, and was trying to use events to write my own version of getActiveCharts in the absence of a built-in method. There is only the singular getActiveChart.

AlexJerabek commented 6 months ago

Thanks for reporting this @NickRedwood. I'm going to transfer it to the office-js repo and get a member of the Excel feature crew to take a look.

NickRedwood commented 6 months ago

Thanks @AlexJerabek

NickRedwood commented 6 months ago

I have found that the Excel.Shape onActivated and onDeactivated methods work correctly for multiple selection, and I think I may be able to use those for Chart, though yet to flesh that out. Unfortunately there is no onActivated and onDeactivated method on ShapeCollection. No getActiveShapes either, or onAdded, onRemoved.

dingjin-ms commented 6 months ago

Thank you @NickRedwood for raising the problem.

  1. For chart.unactivated/ chartCollection.unactivated event bug: I could repro it and opened an internal ticket #8920432 to track it. We will keep you updated if progress is made.
  2. For other apis you mentioned, we apologize for the inconvenience. If you would like to request the features, please post it on our developer forum, where our product managers will regularly review and prioritize the suggestions.
NickRedwood commented 6 months ago

Thanks @dingjin-ms

microsoft-github-policy-service[bot] commented 6 months ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

microsoft-github-policy-service[bot] commented 6 months ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.