-
Notifications
You must be signed in to change notification settings - Fork 973
Hide bookmark bar when removing last item #14048
Conversation
Fix #14047 The bookmark bar has always remained 'visible' when removing the last item. It just happened to be reduced to a few pixels tall. This was a defect as it affected the vertical rhythm of the UI. With #13758, the toolbar always remains the set height. With this change, the toolbar is hidden automatically when the last item is removed, just like it already automatically shows when the first item is added. Test Plan: Automated - `npm run unittest -- --grep 'bookmarksReducer'` Manual - Add several bookmark items, including folders - Remove some items - observe the toolbar is still shown - Move some items - observe the toolbar is still shown - Delete all items - observe the toolbar is not shown anymore - Recreate items, and use 'move' to put all items in a folder that is not on the bookmark bar - observe the toolbar is not shown anymore
@@ -548,6 +560,19 @@ describe('bookmarksReducer unit test', function () { | |||
.deleteIn(['cache', 'bookmarkLocation', 'https://clifton.io/']) | |||
assert.equal(spy.calledOnce, true) | |||
assert.deepEqual(newState.toJS(), expectedState.toJS()) | |||
console.log('settings', newState.get('settings').toJS(), newState.getIn(['settings', settingsConstants.SHOW_BOOKMARKS_TOOLBAR])) |
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.
Whoops, left a console.log in there 😄
@@ -89,6 +94,12 @@ const bookmarksReducer = (state, action, immutableAction) => { | |||
|
|||
const destinationDetail = bookmarksState.findBookmark(state, action.get('destinationKey')) | |||
state = syncUtil.updateObjectCache(state, destinationDetail, STATE_SITES.BOOKMARKS) | |||
|
|||
// close bookmark bar when going to 0 | |||
const bookmarkBarItemCount = bookmarksState.getBookmarksWithFolders(state, 0).size |
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.
A little nit-picky... but could we move this code to app/common/lib/bookmarkUtils? Since it's the same as the code above in bookmarkFoldersReducer.js, each of these could be replaced with a single call (maybe the method would be called like closeBookmarksToolbarIfEmpty
or something like that)
Should make the logic easier to unit test too 😄 👍
assert.ok(onChangeSettingSpy.neverCalledWith(settingsConstants.SHOW_BOOKMARKS_TOOLBAR, false), 'bookmarks toolbar enabled setting is unaffected by removing 1 bookmark') | ||
}) | ||
|
||
it('hides bookmarks toolbar when all toolbar bookmarks are removed', function () { |
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.
Do we need a test for bookmarksReducer too?
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.
Comments left 😄
bae0fcf
to
9b3379f
Compare
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.
Updated the code and tests- works great 😄 👍
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.
Thanks @bsclifton for the more thorough test updates
…items Hide bookmark bar when removing last item
…items Hide bookmark bar when removing last item
Fix #14047
The bookmark bar has always remained 'visible' when removing the last item. It just happened to be reduced to a few pixels tall. This was a defect as it affected the vertical rhythm of the UI. With #13758, the toolbar always remains the set height. With this change, the toolbar is hidden automatically when the last item is removed, just like it already automatically shows when the first item is added.
Also fixes
getSetting
so check for whether an object isImmutable.Map
correctly, so that it can be used in tests.Test Plan:
Automated
npm run unittest -- --grep 'bookmarksReducer'
Manual
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests