Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixing bookmarks toolbar "hover after click" behavior on folders #4361

Merged
merged 3 commits into from
Oct 10, 2016
Merged

Fixing bookmarks toolbar "hover after click" behavior on folders #4361

merged 3 commits into from
Oct 10, 2016

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Sep 28, 2016

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran 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:

  • Added constant to faviconUtils for default icon size (referenced from bookmarksToolbar component)
  • Moved bookmarksToolbar component and faviconUtils to new directory structure

Auditors: @bridiver

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
  7. Drag a bookmark over a bookmark folder and confirm it auto-expands. For bonus points, you can try dragging to a folder inside a folder.

@bsclifton bsclifton added this to the 0.12.4dev milestone Sep 28, 2016
@@ -47,6 +48,21 @@ class BookmarkToolbarButton extends ImmutableComponent {
}
}

onMouseOver (e) {
// Behavior when a bookmarks toolbar folder has its list expanded
if (this.props.selectedFolderId) {
Copy link
Collaborator

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:

  1. It's more inline with how flux is intended to work. We should have declarative actions instead of imperative
  2. 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

Copy link
Member Author

@bsclifton bsclifton Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bridiver:

  1. 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
  2. This particular method (showBookmarkFolderMenu) doesn't use electron.remote. However, there are methods in that file (contextMenus.js) which do (specifically for creating / showing popup menu templates)

Copy link
Collaborator

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.

Copy link
Member Author

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')
Copy link
Member

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')

Copy link
Member Author

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

Copy link
Member Author

@bsclifton bsclifton Oct 4, 2016

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)

@bbondy bbondy removed this from the 0.12.4dev milestone Oct 4, 2016
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
@bsclifton
Copy link
Member Author

bsclifton commented Oct 7, 2016

Chatting w/ ya on Slack now 😄

  • The sites have to be passed (for now) since they come from the appState. FolderId & bookmark are needed (for now- the template methods would need to be updated)
  • I ran into weird issues w/ passing windowState and assigning. I think it has to do with the emit. Will definitely have to revisit this... @bridiver, I'll check this out in a follow-up

@bsclifton bsclifton added this to the 0.12.5dev milestone Oct 7, 2016
@bsclifton
Copy link
Member Author

If @bridiver gives the big thumbs up, let's merge this 😄 Assigning to 0.12.5...

@bridiver
Copy link
Collaborator

++

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants