Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 34bf5f1

Browse files
authored
feat(Chat): Set default chatBehavior which uses Enter/Esc keys (#443)
* Set default chatBehavior which using Enter/Esc keys * Update the description of behavior * Update changelog
1 parent ed616f0 commit 34bf5f1

6 files changed

Lines changed: 5 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2828
### Features
2929
- Make `Grid` keyboard navigable by implementing `gridBehavior` @sophieH29 ([#398](https://github.com/stardust-ui/react/pull/398))
3030
- Set the ref of the `FocusZone` in `Embed` mode @sophieH29 ([#435](https://github.com/stardust-ui/react/pull/435))
31+
- Set default `chatBehavior` which uses Enter/Esc keys @sophieH29 ([#443](https://github.com/stardust-ui/react/pull/443))
3132

3233
### Documentation
3334
- Add all missing component descriptions and improve those existing @levithomason ([#400](https://github.com/stardust-ui/react/pull/400))

src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,9 @@ export {
109109
default as radioGroupItemBehavior,
110110
} from './lib/accessibility/Behaviors/Radio/radioGroupItemBehavior'
111111
export { default as chatBehavior } from './lib/accessibility/Behaviors/Chat/chatBehavior'
112-
export {
113-
default as chatEnterEscBehavior,
114-
} from './lib/accessibility/Behaviors/Chat/chatEnterEscBehavior'
115112
export {
116113
default as chatMessageBehavior,
117114
} from './lib/accessibility/Behaviors/Chat/chatMessageBehavior'
118-
export {
119-
default as chatMessageEnterEscBehavior,
120-
} from './lib/accessibility/Behaviors/Chat/chatMessageEnterEscBehavior'
121115
export { default as gridBehavior } from './lib/accessibility/Behaviors/Grid/gridBehavior'
122116

123117
//

src/lib/accessibility/Behaviors/Chat/chatBehavior.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const CHAT_FOCUSZONE_ATTRIBUTE = 'chat-focuszone'
77
/**
88
* @description
99
* Adds role 'presentation' until we come up with final roles for chat.
10-
* Adds a vertical focus zone navigation with a last message as a default tabbable element, pressing right arrow key focuses inside a message.
11-
* Adds a left arrow key action which focuses the chat, i.e., moves key handling from inside a message back to the chat list.
10+
* Adds a vertical focus zone navigation with a last message as a default tabbable element, pressing enter key focuses inside a message.
11+
* Adds a escape key action which focuses the chat, i.e., moves key handling from inside a message back to the chat list.
1212
*/
1313
const ChatBehavior: Accessibility = (props: any) => ({
1414
attributes: {
@@ -19,7 +19,7 @@ const ChatBehavior: Accessibility = (props: any) => ({
1919
focusZone: {
2020
mode: FocusZoneMode.Wrap,
2121
props: {
22-
shouldEnterInnerZone: event => keyboardKey.getCode(event) === keyboardKey.ArrowRight,
22+
shouldEnterInnerZone: event => keyboardKey.getCode(event) === keyboardKey.Enter,
2323
direction: FocusZoneDirection.vertical,
2424
defaultTabbableElement: `[${CHAT_FOCUSZONE_ATTRIBUTE}] > * > *:last-child`, // select last chat message by default
2525
[CHAT_FOCUSZONE_ATTRIBUTE]: '', // allows querying the default active element
@@ -28,7 +28,7 @@ const ChatBehavior: Accessibility = (props: any) => ({
2828
keyActions: {
2929
root: {
3030
focus: {
31-
keyCombinations: [{ keyCode: keyboardKey.ArrowLeft }],
31+
keyCombinations: [{ keyCode: keyboardKey.Escape }],
3232
},
3333
},
3434
},

src/lib/accessibility/Behaviors/Chat/chatEnterEscBehavior.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/lib/accessibility/Behaviors/Chat/chatMessageEnterEscBehavior.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/lib/accessibility/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,5 @@ export { default as radioGroupBehavior } from './Behaviors/Radio/radioGroupBehav
2121
export { default as radioGroupItemBehavior } from './Behaviors/Radio/radioGroupItemBehavior'
2222
export { default as popupBehavior } from './Behaviors/Popup/popupBehavior'
2323
export { default as chatBehavior } from './Behaviors/Chat/chatBehavior'
24-
export { default as chatEnterEscBehavior } from './Behaviors/Chat/chatEnterEscBehavior'
2524
export { default as chatMessageBehavior } from './Behaviors/Chat/chatMessageBehavior'
26-
export {
27-
default as chatMessageEnterEscBehavior,
28-
} from './Behaviors/Chat/chatMessageEnterEscBehavior'
2925
export { default as gridBehavior } from './Behaviors/Grid/gridBehavior'

0 commit comments

Comments
 (0)