-
Notifications
You must be signed in to change notification settings - Fork 87
refactor: do not disable buttons when moving to overflow #9027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,23 +30,15 @@ describe('overflow', () => { | |
`); | ||
menu = wrapper.querySelector('vaadin-menu-bar'); | ||
await nextRender(menu); | ||
menu.items = [ | ||
{ text: 'Item 1' }, | ||
{ text: 'Item 2' }, | ||
{ text: 'Item 3' }, | ||
{ text: 'Item 4' }, | ||
{ text: 'Item 5', disabled: true }, | ||
]; | ||
menu.items = [{ text: 'Item 1' }, { text: 'Item 2' }, { text: 'Item 3' }, { text: 'Item 4' }, { text: 'Item 5' }]; | ||
await nextUpdate(menu); | ||
buttons = menu._buttons; | ||
overflow = buttons[buttons.length - 1]; | ||
}); | ||
|
||
it('should show overflow button and hide the buttons which do not fit', () => { | ||
assertHidden(buttons[2]); | ||
expect(buttons[2].disabled).to.be.true; | ||
assertHidden(buttons[3]); | ||
expect(buttons[3].disabled).to.be.true; | ||
expect(overflow.hasAttribute('hidden')).to.be.false; | ||
}); | ||
|
||
|
@@ -69,9 +61,7 @@ describe('overflow', () => { | |
menu.style.width = '350px'; | ||
await nextResize(menu); | ||
assertVisible(buttons[2]); | ||
expect(buttons[2].disabled).to.not.be.true; | ||
assertVisible(buttons[3]); | ||
expect(buttons[3].disabled).to.not.be.true; | ||
expect(overflow.item.children.length).to.equal(1); | ||
expect(overflow.item.children[0]).to.deep.equal(menu.items[4]); | ||
}); | ||
|
@@ -81,9 +71,7 @@ describe('overflow', () => { | |
menu.style.width = '350px'; | ||
await nextResize(menu); | ||
assertVisible(buttons[2]); | ||
expect(buttons[2].disabled).to.not.be.true; | ||
assertVisible(buttons[3]); | ||
expect(buttons[3].disabled).to.not.be.true; | ||
expect(overflow.item.children.length).to.equal(1); | ||
expect(overflow.item.children[0]).to.deep.equal(menu.items[4]); | ||
}); | ||
|
@@ -92,7 +80,6 @@ describe('overflow', () => { | |
menu.style.width = '150px'; | ||
await nextResize(menu); | ||
assertHidden(buttons[1]); | ||
expect(buttons[1].disabled).to.be.true; | ||
expect(overflow.item.children.length).to.equal(4); | ||
expect(overflow.item.children[0]).to.deep.equal(menu.items[1]); | ||
expect(overflow.item.children[1]).to.deep.equal(menu.items[2]); | ||
|
@@ -105,7 +92,6 @@ describe('overflow', () => { | |
menu.style.width = '150px'; | ||
await nextResize(menu); | ||
assertHidden(buttons[1]); | ||
expect(buttons[1].disabled).to.be.true; | ||
expect(overflow.item.children.length).to.equal(4); | ||
expect(overflow.item.children[0]).to.deep.equal(menu.items[1]); | ||
expect(overflow.item.children[1]).to.deep.equal(menu.items[2]); | ||
|
@@ -117,11 +103,8 @@ describe('overflow', () => { | |
menu.style.width = 'auto'; | ||
await nextResize(menu); | ||
assertVisible(buttons[2]); | ||
expect(buttons[2].disabled).to.not.be.true; | ||
assertVisible(buttons[3]); | ||
expect(buttons[3].disabled).to.not.be.true; | ||
assertVisible(buttons[4]); | ||
expect(buttons[4].disabled).to.be.true; | ||
expect(overflow.hasAttribute('hidden')).to.be.true; | ||
expect(overflow.item.children.length).to.equal(0); | ||
}); | ||
|
@@ -176,22 +159,6 @@ describe('overflow', () => { | |
await nextResize(menu); | ||
|
||
expect(buttons[0].getAttribute('tabindex')).to.equal('0'); | ||
expect(buttons[1].getAttribute('tabindex')).to.equal('-1'); | ||
}); | ||
|
||
it('should set tabindex -1 on the overflow menu in tab navigation', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a copy-paste of the test above. With |
||
menu.tabNavigation = true; | ||
buttons[0].focus(); | ||
arrowRight(buttons[0]); | ||
|
||
expect(buttons[0].getAttribute('tabindex')).to.equal('0'); | ||
expect(buttons[1].getAttribute('tabindex')).to.equal('0'); | ||
|
||
menu.style.width = '150px'; | ||
await nextResize(menu); | ||
|
||
expect(buttons[0].getAttribute('tabindex')).to.equal('0'); | ||
expect(buttons[1].getAttribute('tabindex')).to.equal('-1'); | ||
}); | ||
|
||
it('should set the aria-label of the overflow button according to the i18n of the menu bar', async () => { | ||
|
@@ -216,15 +183,10 @@ describe('overflow', () => { | |
|
||
it('should show overflow button and hide the buttons which do not fit', () => { | ||
assertHidden(buttons[0]); | ||
expect(buttons[0].disabled).to.be.true; | ||
assertHidden(buttons[1]); | ||
expect(buttons[1].disabled).to.be.true; | ||
assertHidden(buttons[2]); | ||
expect(buttons[2].disabled).to.be.true; | ||
assertVisible(buttons[3]); | ||
expect(buttons[3].disabled).to.be.false; | ||
assertVisible(buttons[4]); | ||
expect(buttons[4].disabled).to.be.true; | ||
|
||
expect(overflow.hasAttribute('hidden')).to.be.false; | ||
}); | ||
|
@@ -242,15 +204,10 @@ describe('overflow', () => { | |
menu.reverseCollapse = false; | ||
await nextUpdate(menu); | ||
assertVisible(buttons[0]); | ||
expect(buttons[0].disabled).to.be.false; | ||
assertVisible(buttons[1]); | ||
expect(buttons[1].disabled).to.be.false; | ||
assertHidden(buttons[2]); | ||
expect(buttons[2].disabled).to.be.true; | ||
assertHidden(buttons[3]); | ||
expect(buttons[3].disabled).to.be.true; | ||
assertHidden(buttons[4]); | ||
expect(buttons[4].disabled).to.be.true; | ||
}); | ||
}); | ||
}); | ||
|
@@ -337,13 +294,7 @@ describe('overflow', () => { | |
|
||
container.style.width = '250px'; | ||
|
||
menu.items = [ | ||
{ text: 'Item 1' }, | ||
{ text: 'Item 2' }, | ||
{ text: 'Item 3' }, | ||
{ text: 'Item 4' }, | ||
{ text: 'Item 5', disabled: true }, | ||
]; | ||
menu.items = [{ text: 'Item 1' }, { text: 'Item 2' }, { text: 'Item 3' }, { text: 'Item 4' }, { text: 'Item 5' }]; | ||
await nextRender(menu); | ||
buttons = menu._buttons; | ||
overflow = buttons[buttons.length - 1]; | ||
|
@@ -357,31 +308,16 @@ describe('overflow', () => { | |
container.style.width = '150px'; | ||
await nextResize(menu); | ||
assertHidden(buttons[2]); | ||
expect(buttons[2].disabled).to.be.true; | ||
assertHidden(buttons[3]); | ||
expect(buttons[3].disabled).to.be.true; | ||
|
||
container.style.width = '400px'; | ||
await nextResize(menu); | ||
assertVisible(buttons[2]); | ||
expect(buttons[2].disabled).to.not.be.true; | ||
assertVisible(buttons[3]); | ||
expect(buttons[3].disabled).to.not.be.true; | ||
assertVisible(buttons[4]); | ||
expect(buttons[4].disabled).to.be.true; | ||
expect(overflow.hasAttribute('hidden')).to.be.true; | ||
expect(overflow.item.children.length).to.equal(0); | ||
}); | ||
|
||
it('should keep buttons disabled when resizing', async () => { | ||
menu.disabled = true; | ||
await nextUpdate(menu); | ||
container.style.width = '150px'; | ||
await nextResize(menu); | ||
buttons.forEach((btn) => { | ||
expect(btn.disabled).to.be.true; | ||
}); | ||
}); | ||
}); | ||
|
||
describe('parent resize', () => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This check is not so relevant for the test, the actual thing is to ensure
tabindex
is set to0
on the first visible button (which hadtabindex="-1"
before resizing above).