diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-02-27 17:14:34 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-02-28 15:03:26 +0100 |
commit | 10e9eeec45773325a69c47c19266d6629e4ea3ca (patch) | |
tree | 8541569576cf736e5cb93edc9b6418f45e7a2010 /apps/files/tests/js | |
parent | 1bcba56d8fecba8d8d64da0f66f51daef1140ead (diff) | |
download | nextcloud-server-10e9eeec45773325a69c47c19266d6629e4ea3ca.tar.gz nextcloud-server-10e9eeec45773325a69c47c19266d6629e4ea3ca.zip |
Fix menu visibility
The crumb for the menu was shown like any other crumb when calling
"_showCrumb", but it was also shown when other crumbs were hidden
without taking into account the available width. This caused several
related problems, like the breadcrumbs taking too much space when the
menu was sometimes shown after the rest of the crumbs were adjusted to
the available width, or the menu being shown instead of the last crumb
even if there was room for it when the available width was increased.
Now the menu is always hidden before starting the resizing of the crumbs
to ensure that whether it was previously shown or not does not affect
the result. In a similar way, the menu will no longer be shown by
"_showCrumb", as it is not a regular crumb that has to be shown simply
if there is enough room. The menu is now shown as soon as any other
crumb is hidden; this ensures that the menu width will be taken into
account in further width checks. As when _updateMenu" is called it no
longer needs to take care of showing the menu this fixes the issue
revealed when fixing the test setup in the previous commit.
Finally, this implicitly fixes the failure in the breadcrumbs tests when
run on Firefox, as it was caused by the menu interfering in the
calculations of the other crumbs when increasing the width.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/tests/js')
-rw-r--r-- | apps/files/tests/js/breadcrumbSpec.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/apps/files/tests/js/breadcrumbSpec.js b/apps/files/tests/js/breadcrumbSpec.js index 3d154f12edd..ebc70f35a78 100644 --- a/apps/files/tests/js/breadcrumbSpec.js +++ b/apps/files/tests/js/breadcrumbSpec.js @@ -529,6 +529,45 @@ describe('OCA.Files.BreadCrumb tests', function() { expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); }); + it('Updates the breadcrumbs when reducing available width taking into account the menu width', function() { + var $crumbs; + + // enough space + $('#controls').width(1800); + bc._resize(); + + $crumbs = bc.$el.find('.crumb'); + + // Menu is hidden + expect($crumbs.eq(0).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(1).hasClass('hidden')).toEqual(false); + + expect($crumbs.eq(2).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(3).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(4).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(5).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); + + // simulate decrease + // 650 is enough for all the crumbs except the third and fourth + // ones, but not enough for the menu and all the crumbs except the + // third and fourth ones; the second one has to be hidden too. + $('#controls').width(650); + bc._resize(); + + // Second, third and fourth crumb are hidden and everything else is + // visible + expect($crumbs.eq(0).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(1).hasClass('hidden')).toEqual(false); + + expect($crumbs.eq(2).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(3).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(4).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(5).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); + }); it('Updates the breadcrumbs when increasing available width', function() { var $crumbs; @@ -564,6 +603,42 @@ describe('OCA.Files.BreadCrumb tests', function() { expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); }); + it('Updates the breadcrumbs when increasing available width taking into account the menu width', function() { + var $crumbs; + + // limited space + $('#controls').width(850); + bc._resize(); + + $crumbs = bc.$el.find('.crumb'); + + // Third and fourth crumb are hidden and everything else is visible + expect($crumbs.eq(0).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(1).hasClass('hidden')).toEqual(false); + + expect($crumbs.eq(2).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(3).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(4).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(5).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); + + // simulate increase + // 1030 is enough for all the crumbs if the menu is hidden. + $('#controls').width(1030); + bc._resize(); + + // Menu is hidden and everything else is visible + expect($crumbs.eq(0).hasClass('hidden')).toEqual(true); + expect($crumbs.eq(1).hasClass('hidden')).toEqual(false); + + expect($crumbs.eq(2).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(3).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(4).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(5).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(6).hasClass('hidden')).toEqual(false); + expect($crumbs.eq(7).hasClass('hidden')).toEqual(false); + }); cit('Updates the breadcrumbs when increasing available width with an expanding sibling', function() { var $crumbs; |