-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(react-infobutton): Popover should close when tabbing out of the surface #28913
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
sopranopillow
merged 11 commits into
microsoft:master
from
sopranopillow:infobutton/dismiss-on-blur
Sep 8, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c277bb3
fix: Popover should close when tabbing out of the surface.
sopranopillow 1dc54a3
change file:
sopranopillow ff9668b
add e2e tests
sopranopillow ca677f7
Merge branch 'master' of https://www.github.com/microsoft/fluentui in…
sopranopillow f2f31f8
Merge branch 'master' into infobutton/dismiss-on-blur
sopranopillow 28b015e
Merge branch 'master' of https://www.github.com/microsoft/fluentui in…
sopranopillow 891ed50
use measured ref instead and simplify logic
sopranopillow 95a55af
Merge branch 'master' of https://www.github.com/microsoft/fluentui in…
sopranopillow 9206b53
fixing deps
sopranopillow e2a7a64
reverting charting
sopranopillow 8b9c6df
Merge branch 'master' into infobutton/dismiss-on-blur
sopranopillow 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-infobutton-e6d4cef7-a090-4513-ac13-c1754d642d63.json
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "fix: Popover should close when tabbing out of the surface.", | ||
| "packageName": "@fluentui/react-infobutton", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { baseConfig } from '@fluentui/scripts-cypress'; | ||
|
|
||
| export default baseConfig; |
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
82 changes: 82 additions & 0 deletions
82
packages/react-components/react-infobutton/src/components/InfoLabel/InfoLabel.cy.tsx
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 |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /// <reference types="cypress-real-events" /> | ||
|
|
||
| import * as React from 'react'; | ||
| import { mount as mountBase } from '@cypress/react'; | ||
| import { FluentProvider } from '@fluentui/react-provider'; | ||
| import { teamsLightTheme } from '@fluentui/react-theme'; | ||
| import { InfoLabel } from '@fluentui/react-infobutton'; | ||
|
|
||
| const mount = (element: JSX.Element) => { | ||
| mountBase(<FluentProvider theme={teamsLightTheme}>{element}</FluentProvider>); | ||
| }; | ||
|
|
||
| const surfaceSelector = '[role="note"]'; | ||
|
|
||
| describe('InfoLabel - close on tab-out', () => { | ||
| const openInfoButton = () => { | ||
| cy.get('button').focus().realPress('{enter}'); | ||
| }; | ||
|
|
||
| it('no focusable elements', () => { | ||
| mount(<InfoLabel label="InfoLabel's label" info="Example non-focusable info" />); | ||
|
|
||
| openInfoButton(); | ||
| cy.realPress(['Shift', 'Tab']).get(surfaceSelector).should('not.exist'); | ||
| openInfoButton(); | ||
| cy.realPress('Tab').get(surfaceSelector).should('not.exist'); | ||
| }); | ||
|
|
||
| it('single focusable element', () => { | ||
| mount( | ||
| <InfoLabel | ||
| label="InfoLabel's label" | ||
| info={ | ||
| <> | ||
| Example non-focusable info | ||
| <button>one</button> | ||
| </> | ||
| } | ||
| />, | ||
| ); | ||
|
|
||
| openInfoButton(); | ||
| cy.realPress(['Shift', 'Tab']).get(surfaceSelector).should('not.exist'); | ||
| openInfoButton(); | ||
| // moving into the focusable item | ||
| cy.realPress('Tab').get(surfaceSelector).should('exist'); | ||
| // tabbing out with shift + tab from the first focusable item should close the surface since | ||
| // the surface is only focusable programmatically | ||
| cy.realPress(['Shift', 'Tab']).get(surfaceSelector).should('not.exist'); | ||
| openInfoButton(); | ||
| cy.realPress('Tab').realPress('Tab').get(surfaceSelector).should('not.exist'); | ||
| }); | ||
|
|
||
| it('one or more focusable elements', () => { | ||
| mount( | ||
| <InfoLabel | ||
| label="InfoLabel's label" | ||
| info={ | ||
| <> | ||
| Example non-focusable info | ||
| <button>one</button> | ||
| <button>two</button> | ||
| <button>three</button> | ||
| </> | ||
| } | ||
| />, | ||
| ); | ||
|
|
||
| openInfoButton(); | ||
| cy.realPress(['Shift', 'Tab']).get(surfaceSelector).should('not.exist'); | ||
| openInfoButton(); | ||
| // moving into the focusable item | ||
| cy.realPress('Tab').get(surfaceSelector).should('exist'); | ||
| // tabbing out with shift + tab from the first focusable item should close the surface since | ||
| // the surface is only focusable programmatically | ||
| cy.realPress(['Shift', 'Tab']).get(surfaceSelector).should('not.exist'); | ||
| openInfoButton(); | ||
| // checking that event does not propagate to children | ||
| cy.realPress('Tab').realPress('Tab').realPress(['Shift', 'Tab']).get(surfaceSelector).should('exist'); | ||
| cy.realPress('Tab').realPress('Tab').realPress('Tab').get(surfaceSelector).should('not.exist'); | ||
| }); | ||
| }); |
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "isolatedModules": false, | ||
| "types": ["node", "cypress", "cypress-storybook/cypress", "cypress-real-events"], | ||
| "lib": ["ES2019", "dom"] | ||
| }, | ||
| "include": ["**/*.cy.ts", "**/*.cy.tsx"] | ||
| } |
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 |
|---|---|---|
|
|
@@ -20,6 +20,9 @@ | |
| }, | ||
| { | ||
| "path": "./.storybook/tsconfig.json" | ||
| }, | ||
| { | ||
| "path": "./tsconfig.cy.json" | ||
| } | ||
| ] | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.