-
Notifications
You must be signed in to change notification settings - Fork 975
Fixing bookmarks toolbar "hover after click" behavior on folders #4361
Conversation
@@ -47,6 +48,21 @@ class BookmarkToolbarButton extends ImmutableComponent { | |||
} | |||
} | |||
|
|||
onMouseOver (e) { | |||
// Behavior when a bookmarks toolbar folder has its list expanded | |||
if (this.props.selectedFolderId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that ideally this should trigger something like an onMouseOverBookmarkFolder
action with whatever params are needed to allow the windowstore (browser process eventually) to update the state rather than having the logic here to open context menus and update state. The are two reasons for this:
- It's more inline with how flux is intended to work. We should have declarative actions instead of imperative
- We want to take node out of the main window renderers so we want to move electron api calls out of the react components (showBookmarkFolderMenu indirectly calls
electron.remote
methods) in preparation for moving them to the browser process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I can update the code to do this. It would be a larger change and would put "business logic" into the WindowStore. For example, if the selection changes from null or -1 to a valid number, the WindowStore would know it needs to create a ContextMenu renderer control, which I guess it would handle by doing another windowAction? Maybe we can talk this out more
- This particular method (
showBookmarkFolderMenu
) doesn't useelectron.remote
. However, there are methods in that file (contextMenus.js
) which do (specifically for creating / showing popup menu templates)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at this.props.showBookmarkFolderMenu
which at first looked like it called the electron api directly, but it calls setContextMenuDetails
which eventually triggers a call the remote api. The windowStore really should directly care about any of this, the logic itself should be in a "reducer" similar extensionState
. In the flux/redux model that is exactly where the logic is supposed to go. The UI should just fire off events and react to state changes. We have a bit of code to untangle because actions shouldn't call other actions, but some of the actions are "setters" and aren't written in a way that makes it easy to reuse the login in them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented feedback- ready for re-review @bridiver 😄
// .keys('ArrowDown') | ||
// .keys('ArrowDown') | ||
// .keys('ArrowDown') | ||
// .keys('Enter') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can try .click('.contextMenuItemText=Add Folder')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdh thanks for checking this out- I did end up looking at it more and unfortunately, the menu that pops up is a system popup (not one of our custom rendered context menus, like autofill 😞). I'll remove the commented out tests for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up- I did find a way to test adding bookmark folders (see commits)
When context menu is expanded for a bookmark folder, mousing over other folders will auto-expand them (closing your previous folder's context menu). Matching behavior in Chrome, mousing over non-folders will hide the menu. Fixes #1725 Also includes: - Added constant to faviconUtils for default icon size (referenced from bookmarksToolbar component) - Moved bookmarksToolbar component and faviconUtils to new directory structure Auditors: @bbondy @darkdh Test Plan: 1. Launch Brave and ensure you have bookmarks toolbar showing with at least 2 folders and 1 non-folder 2. Click one of the folders in bookmarks toolbar and confirm it opens 3. Mouse over the other folder and confirm it auto-expands the menu 4. Mouse over a non-folder (ex: a bookmark) and confirm it hides the menu 5. Mouse back over a folder and confirm it auto-expands it again 6. Click anywhere to dismiss the context menu
…ew functionality - Some cleanup, per comments, cc: @bridiver
Chatting w/ ya on Slack now 😄
|
If @bridiver gives the big thumbs up, let's merge this 😄 Assigning to 0.12.5... |
++ |
git rebase -i
to squash commits (if needed).When context menu is expanded for a bookmark folder, mousing over other folders will auto-expand them (closing your previous folder's context menu).
Matching behavior in Chrome, mousing over non-folders will hide the menu.
Fixes #1725
Also includes:
Auditors: @bridiver
Test Plan