sheetkeys
sheetkeys copied to clipboard
Implement command to resize the current column to fit its contents
You can see this dialog by clicking on the "resize" button in a column's context menu.
I've been playing around with trying to implement this, but am a bit stuck:
- To bring up the current cell's column's context menu, I first tried to find that column's down-arrow button and click that, but it seems that maybe each column shares the same element (query
".waffle-kennedy-column-menu-button"
) for the down arrow, just drawn in different places, with the state of which column was clicked stored... somewhere? So when I would simulate a click on the button, the context menu would appear Then I tried simply right clicking on the column header, using the logic fromselectColumn
and a modified version ofsimulateClick
to support right-click. This mostly works, but I'm not sure if it's the best approach. Also, if the column is already selected, then this selects column A. - Once I have the column context menu open, I cannot figure out how to reliably click on the "Resize column" button. If I first bring up the context menu, then call
this.clickMenu("Resize column")
, the resize modal opens correctly maybe half the time; the other half doing nothing, leaving the context menu hanging open. I suspect it might be some kind of race condition between the context menu opening and theclickMenu
call. Maybe there's a way to wait until the context menu is open? - I haven't tried to automate navigation of the modal yet, but I'm thinking it should be more straightforward.
A lot of my difficulty stems from the fact that I can't seem to inspect the context menu using dev tools, because any time I click away from the context menu (e.g. to Inspect Element), it vanishes immediately. Maybe there's some trick I don't know about?
It's possible that there's no really good way to access this menu, based on how Google has structured it; but I'd rather hold hope. 😛 Any advice on further paths to explore would be appreciated. I'm learning a lot about how DOMs can be structured in these single-page-applications, and I'm naive to a lot of techniques (I imagine); so it's possible I'm missing something obvious.