-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Focus should not blur briefly after tapping on a suggested action (#5097
- Loading branch information
Showing
15 changed files
with
323 additions
and
60 deletions.
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
65 changes: 65 additions & 0 deletions
65
__tests__/html/accessibility.suggestedActions.sendFocusImmediately.html
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,65 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="/test-harness.js"></script> | ||
<script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script> | ||
run(async function () { | ||
WebChat.renderWebChat( | ||
{ | ||
directLine: testHelpers.createDirectLineWithTranscript([ | ||
{ | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
suggestedActions: { | ||
actions: [ | ||
{ | ||
type: 'imBack', | ||
value: 'What can I say?' | ||
}, | ||
{ | ||
type: 'imBack', | ||
value: 'What is the weather?' | ||
} | ||
] | ||
}, | ||
textFormat: 'markdown', | ||
timestamp: new Date(2000, 0, 1, 12, 34, 56, 789).toISOString(), | ||
type: 'message' | ||
} | ||
]), | ||
store: testHelpers.createStore(), | ||
styleOptions: { | ||
suggestedActionLayout: 'stacked' | ||
} | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.uiConnected(); | ||
await pageConditions.suggestedActionsShown(); | ||
|
||
// THEN: Suggested actions container in stacked layout should be of `role="toolbar"` with `aria-orientation="vertical"` | ||
const [firstSuggestedAction] = pageElements.suggestedActions(); | ||
|
||
let elementBeforeClick; | ||
|
||
pageElements.sendBoxTextBox().focus = () => { | ||
elementBeforeClick = document.activeElement; | ||
}; | ||
|
||
await host.click(firstSuggestedAction); | ||
|
||
expect(elementBeforeClick).not.toBe(document.body); | ||
expect(elementBeforeClick).toBe(firstSuggestedAction); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
__tests__/html/accessibility.suggestedActions.sendFocusImmediately.js
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,7 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility requirement', () => { | ||
describe('after clicking on suggested action', () => { | ||
test('should send the focus to send box immediately', () => runHTML('accessibility.suggestedActions.sendFocusImmediately.html')); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
import { createContext, type MutableRefObject } from 'react'; | ||
|
||
import { type FocusSendBoxInit } from '../../types/internal/FocusSendBoxInit'; | ||
import { type FocusTranscriptInit } from '../../types/internal/FocusTranscriptInit'; | ||
|
||
export type ContextType = { | ||
focusSendBoxCallbacksRef: MutableRefObject<((init: FocusSendBoxInit) => Promise<void>)[]>; | ||
focusTranscriptCallbacksRef: MutableRefObject<((init: FocusTranscriptInit) => Promise<void>)[]>; | ||
}; | ||
|
||
const context = createContext<ContextType>(undefined as ContextType); | ||
|
||
export default context; |
Oops, something went wrong.