Skip to content

Commit 6ff90db

Browse files
authored
Fluent: fix DTMF key command usage (#5198)
* Fix DTMF key command usage * Changelog * Fix star and pound
1 parent 7ced5fa commit 6ff90db

7 files changed

Lines changed: 27 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
3434
- Improved performance for `useMemoized`, in PR [5190](https://github.com/microsoft/BotFramework-WebChat/pull/5190), by [@OEvgeny](https://github.com/OEvgeny)
3535
- Fixed send box zoomed in when clicked on mobile Safari, in PR [5192](https://github.com/microsoft/BotFramework-WebChat/pull/5192), by [@OEvgeny](https://github.com/OEvgeny)
3636
- Added missing support for chat history scroll with keyboard when Fluent send box is focused, in PR [5191](https://github.com/microsoft/BotFramework-WebChat/pull/5191), by [@OEvgeny](https://github.com/OEvgeny)
37+
- Fixed DTMF command usage sent by telephone keypad, in PR [5198](https://github.com/microsoft/BotFramework-WebChat/pull/5198), by [@OEvgeny](https://github.com/OEvgeny)
3738

3839
### Changed
3940

Loading

__tests__/html/fluentTheme/telephoneKeypad.tap.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,29 @@
4545
await host.click(pageElements.byTestId(WebChat.testIds.sendBoxTelephoneKeypadToolbarButton));
4646

4747
await (
48-
await directLine.actPostActivity(() =>
48+
await directLine.actPostActivity(() =>
49+
host.click(pageElements.byTestId(WebChat.testIds.sendBoxTelephoneKeypadButtonPound))
50+
)
51+
).resolveAll();
52+
53+
await (
54+
await directLine.actPostActivity(() =>
55+
host.click(pageElements.byTestId(WebChat.testIds.sendBoxTelephoneKeypadButtonStar))
56+
)
57+
).resolveAll();
58+
59+
await (
60+
await directLine.actPostActivity(() =>
4961
host.click(pageElements.byTestId(WebChat.testIds.sendBoxTelephoneKeypadButton5))
5062
)
5163
).resolveAll();
5264

53-
// THEN: Should send "/DTMF 5".
54-
await pageConditions.numActivitiesShown(2);
55-
expect(pageElements.activityContents()[1]).toHaveProperty('textContent', '/DTMF 5');
65+
66+
// THEN: Should send "/DTMFKey 5".
67+
await pageConditions.numActivitiesShown(4);
68+
expect(pageElements.activityContents()[1]).toHaveProperty('textContent', '/DTMFKey #');
69+
expect(pageElements.activityContents()[2]).toHaveProperty('textContent', '/DTMFKey *');
70+
expect(pageElements.activityContents()[3]).toHaveProperty('textContent', '/DTMFKey 5');
5671

5772
// THEN: Should not close the keypad and keep focusing on the button "5".
5873
expect(pageElements.byTestId(WebChat.testIds.sendBoxTelephoneKeypadButton5)).toBeTruthy();

packages/fluent-theme/src/components/sendBox/SendBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function SendBox(
143143

144144
const handleTelephoneKeypadButtonClick = useCallback(
145145
// TODO: We need more official way of sending DTMF.
146-
(dtmf: DTMF) => sendMessage(`/DTMF ${dtmf}`),
146+
(dtmf: DTMF) => sendMessage(`/DTMFKey ${dtmf}`),
147147
[sendMessage]
148148
);
149149

packages/fluent-theme/src/components/telephoneKeypad/private/Button.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ const Button = memo(
2929
ref={ref}
3030
type="button"
3131
>
32-
<span className={classNames['telephone-keypad__button__text']}>
33-
{button === 'star' ? '\u2217' : button === 'pound' ? '#' : button}
34-
</span>
32+
<span className={classNames['telephone-keypad__button__text']}>{button === '*' ? '\u2217' : button}</span>
3533
{!!ruby && <ruby className={classNames['telephone-keypad__button__ruby']}>{ruby}</ruby>}
3634
</button>
3735
);

packages/fluent-theme/src/components/telephoneKeypad/private/TelephoneKeypad.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const TelephoneKeypad = memo(({ autoFocus, className, onButtonClick, isHorizonta
5050
const handleButton8Click = useCallback(() => onButtonClickRef.current?.('8'), [onButtonClickRef]);
5151
const handleButton9Click = useCallback(() => onButtonClickRef.current?.('9'), [onButtonClickRef]);
5252
const handleButton0Click = useCallback(() => onButtonClickRef.current?.('0'), [onButtonClickRef]);
53-
const handleButtonStarClick = useCallback(() => onButtonClickRef.current?.('star'), [onButtonClickRef]);
54-
const handleButtonPoundClick = useCallback(() => onButtonClickRef.current?.('pound'), [onButtonClickRef]);
53+
const handleButtonStarClick = useCallback(() => onButtonClickRef.current?.('*'), [onButtonClickRef]);
54+
const handleButtonPoundClick = useCallback(() => onButtonClickRef.current?.('#'), [onButtonClickRef]);
5555
const handleKeyDown = useCallback<KeyboardEventHandler<HTMLDivElement>>(
5656
event => {
5757
if (event.key === 'Escape') {
@@ -123,13 +123,9 @@ const TelephoneKeypad = memo(({ autoFocus, className, onButtonClick, isHorizonta
123123
onClick={handleButton9Click}
124124
ruby="WXYZ"
125125
/>
126-
<Button button="star" data-testid={testIds.sendBoxTelephoneKeypadButtonStar} onClick={handleButtonStarClick} />
126+
<Button button="*" data-testid={testIds.sendBoxTelephoneKeypadButtonStar} onClick={handleButtonStarClick} />
127127
<Button button="0" data-testid={testIds.sendBoxTelephoneKeypadButton0} onClick={handleButton0Click} ruby="+" />
128-
<Button
129-
button="pound"
130-
data-testid={testIds.sendBoxTelephoneKeypadButtonPound}
131-
onClick={handleButtonPoundClick}
132-
/>
128+
<Button button="#" data-testid={testIds.sendBoxTelephoneKeypadButtonPound} onClick={handleButtonPoundClick} />
133129
</Orientation>
134130
<div className={classNames['telephone-keypad__info-message']}>
135131
<InfoSmallIcon />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type DTMF = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '0' | 'star' | 'pound';
1+
export type DTMF = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '0' | '*' | '#';

0 commit comments

Comments
 (0)