Skip to content
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

#2608 Return focus to sendbox after clicking New Messages or Suggested Actions Button #2628

Merged
merged 3 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#2559](https://github.com/microsoft/BotFramework-WebChat/issues/2559). De-bump remark and strip-markdown, by [@corinagum](https://github.com/corinagum) in PR [#2576](https://github.com/microsoft/BotFramework-WebChat/pull/2576)
- Fixes [#2512](https://github.com/microsoft/BotFramework-WebChat/issues/2512). Adds check to ensure Adaptive Card's content is an Object, by [@tdurnford](https://github.com/tdurnford) in PR [#2590](https://github.com/microsoft/BotFramework-WebChat/pull/2590)
- Fixes [#1780](https://github.com/microsoft/BotFramework-WebChat/issues/1780), [#2277](https://github.com/microsoft/BotFramework-WebChat/issues/2277), and [#2285](https://github.com/microsoft/BotFramework-WebChat/issues/2285). Make Suggested Actions accessible, Fix Markdown card in carousel being read multiple times, and label widgets of Connectivity Status and Suggested Actions containers, by [@corinagum](https://github.com/corinagum) in PR [#2613](https://github.com/microsoft/BotFramework-WebChat/pull/2613)
- Fixes [#2608](https://github.com/microsoft/BotFramework-WebChat/issues/2608). Focus will return to sendbox after clicking New Messages or a Suggested Actions button, by [@corinagum](https://github.com/corinagum) in PR [#2628](https://github.com/microsoft/BotFramework-WebChat/pull/2628)

### Added

Expand Down
11 changes: 9 additions & 2 deletions packages/component/src/Activity/ScrollToEndButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ import { StateContext as ScrollToBottomStateContext } from 'react-scroll-to-bott

import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import React, { useCallback } from 'react';

import Localize from '../Localization/Localize';
import useFocusSendBox from '../hooks/useFocusSendBox';
import useScrollToEnd from '../hooks/useScrollToEnd';
import useStyleSet from '../hooks/useStyleSet';

const ScrollToEndButton = ({ className }) => {
const [{ scrollToEndButton: scrollToEndButtonStyleSet }] = useStyleSet();
const focusSendBox = useFocusSendBox();
const scrollToEnd = useScrollToEnd();

const handleClick = useCallback(() => {
scrollToEnd();
focusSendBox();
}, [focusSendBox, scrollToEnd]);

return (
<button className={classNames(scrollToEndButtonStyleSet + '', className + '')} onClick={scrollToEnd} type="button">
<button className={classNames(scrollToEndButtonStyleSet + '', className + '')} onClick={handleClick} type="button">
<Localize text="New messages" />
</button>
);
Expand Down
5 changes: 4 additions & 1 deletion packages/component/src/SendBox/SuggestedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useCallback } from 'react';

import connectToWebChat from '../connectToWebChat';
import useDisabled from '../hooks/useDisabled';
import useFocusSendBox from '../hooks/useFocusSendBox';
import usePerformCardAction from '../hooks/usePerformCardAction';
import useStyleSet from '../hooks/useStyleSet';
import useSuggestedActions from '../hooks/useSuggestedActions';
Expand Down Expand Up @@ -35,12 +36,14 @@ const SuggestedAction = ({ 'aria-hidden': ariaHidden, buttonText, displayText, i
const [_, setSuggestedActions] = useSuggestedActions();
const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
const [disabled] = useDisabled();
const focusSendBox = useFocusSendBox();
const performCardAction = usePerformCardAction();

const handleClick = useCallback(() => {
performCardAction({ displayText, text, type, value });
type === 'openUrl' && setSuggestedActions([]);
}, [displayText, performCardAction, setSuggestedActions, text, type, value]);
focusSendBox();
}, [displayText, focusSendBox, performCardAction, setSuggestedActions, text, type, value]);

return (
<div aria-hidden={ariaHidden} className={classNames(suggestedActionStyleSet + '', SUGGESTED_ACTION_CSS + '')}>
Expand Down