[Reland] Change ActionsController to only update DOM when displaying a menu
Previously ActionsController would calculate the additional actions for Drive (share, create-shortcut, etc) and FSP [1] like change directory, selection changed, and metadata updated. When these events arrive in FilesApp, they update the <command> and <cr-menu> DOM state. However, that can cause flickering in visible menus and also flakes in browser tests based on menus, since these events can happen while the menu is displayed for an entry or set of entries (selection) or affect entries other than those associated with the menu. This CL changes ActionsController to store state in an internal map, rather than in the DOM, and to only update the menu DOM state when a user-action shows the menu. Change CommandHandler to set the visibility for Drive actions/commands synchronously to avoid flickering the size of the menu - it still can flicker the disabled state and pinned check-mark, but these are softer to human eyes than the change in size. Change ToolbarController to update its refresh button disabled state. The button relied on FileManagerCommands to update the |refresh| state command, which was not correct because the refresh button always acts on the current directory, whereas the command was being evaluated for different entries. Change Action models and derived classes to have a |getEntries| method so that ActionsController can get the entries that it is acting upon to invalidate the state prior to executation. Change ActionsSubMenu.setActionsModel to forward the target element, so the <command> can be updated to the correct target element. [1] https://developer.chrome.com/apps/fileSystemProvider#event-onGetActionsRequested Bug: 889153, 875446, 961244 Change-Id: I059f4516f0b64426a7570a88d8eff7e48b435454 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605383Reviewed-by:Noel Gordon <noel@chromium.org> Commit-Queue: Noel Gordon <noel@chromium.org> Cr-Commit-Position: refs/heads/master@{#658458}
Showing
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment