-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Popup): new prop
closeOnScroll
close popup when scroll outside…
… of it (#21453) * close on scroll * chglog * e2e
- Loading branch information
1 parent
096e9ba
commit a8158d3
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
52 changes: 52 additions & 0 deletions
52
packages/fluentui/e2e/tests/popupDismissScroll-example.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { Button, Popup, Flex } from '@fluentui/react-northstar'; | ||
|
||
export const selectors = { | ||
simplePopup: { | ||
triggerId: 'trigger', | ||
contentId: 'content', | ||
}, | ||
contextPopup: { | ||
triggerId: 'trigger-context', | ||
contentId: 'content-context', | ||
}, | ||
dismissScrollPopup: { | ||
triggerId: 'trigger-dismiss', | ||
contentId: 'content-dismiss', | ||
}, | ||
}; | ||
|
||
const PopupClickHandlingExample = () => { | ||
return ( | ||
<Flex column> | ||
simple popup | ||
<Popup | ||
trigger={<Button id={selectors.simplePopup.triggerId} content="Open Popup" />} | ||
content={{ | ||
content: 'Open a popup', | ||
id: selectors.simplePopup.contentId, | ||
}} | ||
/> | ||
popup open on context | ||
<Popup | ||
trigger={<Button id={selectors.contextPopup.triggerId} content="Open Popup" />} | ||
content={{ | ||
content: 'Open a popup', | ||
id: selectors.contextPopup.contentId, | ||
}} | ||
on="context" | ||
/> | ||
popup with closeOnScroll | ||
<Popup | ||
trigger={<Button id={selectors.dismissScrollPopup.triggerId} content="Open Popup" />} | ||
content={{ | ||
content: 'Open a popup', | ||
id: selectors.dismissScrollPopup.contentId, | ||
}} | ||
closeOnScroll | ||
/> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default PopupClickHandlingExample; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { selectors } from './popupDismissScroll-example'; | ||
|
||
describe('Popup - dismiss on scroll container', () => { | ||
beforeEach(() => { | ||
cy.gotoTestCase(__filename, `#${selectors.simplePopup.triggerId}`); | ||
}); | ||
|
||
it('simple popup does not dismiss content on scroll', () => { | ||
cy.clickOn(`#${selectors.simplePopup.triggerId}`); // opens popup | ||
cy.visible(`#${selectors.simplePopup.contentId}`); // popup visible | ||
cy.get('body').trigger('wheel'); // page scroll | ||
cy.visible(`#${selectors.simplePopup.contentId}`); // popup still visible | ||
}); | ||
|
||
it('popup on context dismiss content on scroll', () => { | ||
cy.get(`#${selectors.contextPopup.triggerId}`).rightclick(); // opens popup | ||
cy.visible(`#${selectors.contextPopup.contentId}`); // popup visible | ||
cy.get('body').trigger('wheel'); // page scroll | ||
cy.notExist(`#${selectors.contextPopup.contentId}`); // popup dismissed | ||
}); | ||
|
||
it('popup with closeOnScroll prop dismiss content on scroll', () => { | ||
cy.clickOn(`#${selectors.dismissScrollPopup.triggerId}`); // opens popup | ||
cy.visible(`#${selectors.dismissScrollPopup.contentId}`); // popup visible | ||
cy.get('body').trigger('wheel'); // page scroll | ||
cy.notExist(`#${selectors.dismissScrollPopup.contentId}`); // popup dismissed | ||
}); | ||
}); |
This file contains 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