Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "added ariaLabel in InputBoxButtonProps and strings for EditBox buttons in MessageThreadStrings",
"packageName": "@internal/react-components",
"email": "alcail@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "updated Sendbox and EditBox styles",
"packageName": "@internal/react-composites",
"email": "alcail@microsoft.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "updated Sendbox custom styles",
"packageName": "@internal/storybook",
"email": "alcail@microsoft.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ export type InputBoxButtonProps = {
onClick: (e: React_2.MouseEvent<HTMLDivElement, MouseEvent>) => void;
className?: string;
id?: string;
ariaLabel?: string;
};

// @public
Expand Down Expand Up @@ -1485,7 +1486,9 @@ export type MessageThreadSelector = (state: ChatClientState, props: ChatBaseSele

// @public
export interface MessageThreadStrings {
editBoxCancelButton: string;
editBoxPlaceholderText: string;
editBoxSubmitButton: string;
editBoxTextLimit: string;
editedTag: string;
editMessage: string;
Expand Down
3 changes: 3 additions & 0 deletions packages/react-components/review/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export type InputBoxButtonProps = {
onClick: (e: React_2.MouseEvent<HTMLDivElement, MouseEvent>) => void;
className?: string;
id?: string;
ariaLabel?: string;
};

// @public
Expand Down Expand Up @@ -477,7 +478,9 @@ export type MessageThreadProps = {

// @public
export interface MessageThreadStrings {
editBoxCancelButton: string;
editBoxPlaceholderText: string;
editBoxSubmitButton: string;
editBoxTextLimit: string;
editedTag: string;
editMessage: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const ChatMessageComponent = (props: ChatMessageProps): JSX.Element => {

const { message, onUpdateMessage, onDeleteMessage, disableEditing, showDate, messageContainerStyle, strings } = props;
const [isEditing, setIsEditing] = useState(false);
const [hideContextMenu, setHideContextMenu] = useState<boolean>(true);

const longPressProps = useLongPress(() => console.log('Long press finished'), {
captureEvent: true,
Expand All @@ -114,16 +115,21 @@ export const ChatMessageComponent = (props: ChatMessageProps): JSX.Element => {
iconOnly: true,
activeIndex: -1,
className: menuClass,
onItemClick: () => {
setHideContextMenu(false);
},
items: [
{
children: (
<MoreMenu
hideContextMenu={hideContextMenu}
onEditClick={() => {
setIsEditing(true);
}}
onRemoveClick={async () => {
onDeleteMessage && message.messageId && (await onDeleteMessage(message.messageId));
}}
onDismiss={() => setHideContextMenu(true)}
strings={strings}
/>
),
Expand All @@ -133,7 +139,7 @@ export const ChatMessageComponent = (props: ChatMessageProps): JSX.Element => {
}
]
}),
[menuClass, message.messageId, onDeleteMessage, strings]
[menuClass, message.messageId, onDeleteMessage, strings, hideContextMenu]
);

if (message.messageType !== 'chat') {
Expand Down Expand Up @@ -188,16 +194,19 @@ export const ChatMessageComponent = (props: ChatMessageProps): JSX.Element => {
};

const MoreMenu = ({
hideContextMenu,
onEditClick,
onRemoveClick,
onDismiss,
strings
}: {
hideContextMenu: boolean;
onEditClick: () => void;
onRemoveClick: () => void;
onDismiss: () => void;
strings: MessageThreadStrings;
}): JSX.Element => {
const menuRef = useRef<HTMLDivElement | null>(null);
const [menuHidden, setMenuHidden] = useState(true);

const menuItems = useMemo(
(): IContextualMenuItem[] => [
Expand All @@ -224,16 +233,15 @@ const MoreMenu = ({
<div ref={menuRef}>
<MoreIcon
className={iconWrapperStyle}
onClick={() => setMenuHidden(false)}
{...{
outline: true
}}
/>
<ContextualMenu
items={menuItems}
hidden={menuHidden}
hidden={hideContextMenu}
target={menuRef}
onDismiss={() => setMenuHidden(true)}
onDismiss={() => onDismiss()}
directionalHint={DirectionalHint.bottomLeftEdge}
className={chatMessageMenuStyle}
/>
Expand Down
13 changes: 11 additions & 2 deletions packages/react-components/src/components/EditBox.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { concatStyleSets, Icon, mergeStyles } from '@fluentui/react';
import { concatStyleSets, Icon, ITextField, mergeStyles } from '@fluentui/react';
import { _formatString } from '@internal/acs-ui-common';
import { useTheme } from '../theming/FluentThemeProvider';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';

import { editBoxStyle, inputBoxIcon, editingButtonStyle, editBoxStyleSet } from './styles/EditBox.styles';
import { InputBoxButton, InputBoxComponent } from './InputBoxComponent';
Expand Down Expand Up @@ -39,8 +39,13 @@ export const EditBox = (props: EditBoxProps): JSX.Element => {
const { onCancel, onSubmit, initialValue, strings } = props;
const [textValue, setTextValue] = useState<string>(initialValue);
const [textValueOverflow, setTextValueOverflow] = useState(false);
const editTextFieldRef = React.useRef<ITextField>(null);
const theme = useTheme();

useEffect(() => {
editTextFieldRef.current?.focus();
}, []);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't lint complain about dependencies here? editTextFieldRef.current should be in the dependency array.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no complain, having an empty array will go through this only when component mount, and that's what we want to be able to have the cursor on the TextTield when EditBox opens


const setText = (
event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>,
newValue?: string | undefined
Expand Down Expand Up @@ -75,6 +80,8 @@ export const EditBox = (props: EditBoxProps): JSX.Element => {

return (
<InputBoxComponent
id={'editbox'}
textFieldRef={editTextFieldRef}
inputClassName={editBoxStyle}
placeholderText={strings.editBoxPlaceholderText}
textValue={textValue}
Expand All @@ -89,6 +96,7 @@ export const EditBox = (props: EditBoxProps): JSX.Element => {
>
<InputBoxButton
className={editingButtonStyle}
ariaLabel={strings.editBoxCancelButton}
onRenderIcon={onRenderThemedCancelIcon}
onClick={() => {
onCancel && onCancel();
Expand All @@ -97,6 +105,7 @@ export const EditBox = (props: EditBoxProps): JSX.Element => {
/>
<InputBoxButton
className={editingButtonStyle}
ariaLabel={strings.editBoxSubmitButton}
onRenderIcon={onRenderThemedSubmitIcon}
onClick={(e) => {
if (!textValueOverflow && textValue !== '') {
Expand Down
19 changes: 10 additions & 9 deletions packages/react-components/src/components/InputBoxComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import React, { useState, ReactNode, FormEvent, useCallback } from 'react';
import { Stack, TextField, mergeStyles, IStyle, ITextField, concatStyleSets } from '@fluentui/react';
import { Stack, TextField, mergeStyles, IStyle, ITextField, concatStyleSets, IconButton } from '@fluentui/react';
import { BaseCustomStyles } from '../types';
import {
inputBoxStyle,
Expand Down Expand Up @@ -130,28 +130,29 @@ export type InputBoxButtonProps = {
onClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
className?: string;
id?: string;
ariaLabel?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, InputBoxButtonProps should inherit from IButtonProps and pass through those props to the IconButton.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after discussion and the fact that onRenderIcon is not defined the same way between the 2 props due to rendering different icon depending on hovering state, I will not do this inheritance.
I will indeed revisit the API though but in a following PR

};

/**
* @private
*/
export const InputBoxButton = (props: InputBoxButtonProps): JSX.Element => {
const { onRenderIcon, onClick, className, id } = props;
const [isMouseOverSendIcon, setIsMouseOverSendIcon] = useState(false);
const { onRenderIcon, onClick, ariaLabel, className, id } = props;
const [isMouseOverIcon, setIsMouseOverIcon] = useState(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit.

Something feels very wrong about us holding onto the state that tells us if we are hovering over the icon.
If this makes sense to everyone else tho then lets land it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but was part of component before, so I did not want to touch that. Now that we want the props to be an extension of IButtonProps, I have to revisit this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue here is that we have a complete different icon when overring

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a question to FluentUI team. Will follow up

const mergedButtonStyle = mergeStyles(inputButtonStyle, className);
return (
<div
<IconButton
className={mergedButtonStyle}
ariaLabel={ariaLabel}
onClick={onClick}
id={id}
onMouseEnter={() => {
setIsMouseOverSendIcon(true);
setIsMouseOverIcon(true);
}}
onMouseLeave={() => {
setIsMouseOverSendIcon(false);
setIsMouseOverIcon(false);
}}
>
{onRenderIcon(props, isMouseOverSendIcon)}
</div>
onRenderIcon={() => onRenderIcon(props, isMouseOverIcon)}
/>
);
};
4 changes: 4 additions & 0 deletions packages/react-components/src/components/MessageThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export interface MessageThreadStrings {
newMessagesIndicator: string;
/** String for replacing display name when there is none*/
noDisplayNameSub: string;
/** String for Cancel button in EditBox*/
editBoxCancelButton: string;
/** String for Submit in EditBox when there is no user input*/
editBoxSubmitButton: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ export const textFieldStyle = (errorColor: string, hasErrorMessage: boolean, dis
*/
export const inputButtonStyle = mergeStyles({
color: 'grey',
cursor: 'pointer',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would have preferred these style changes to be in a separate PR.

Most of the e2e snapshot changes are due to these, unrelated to the non-trivial code changes elsewhere in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the PR. Styles need to be changed due to using IconButton

display: 'flex',
justifyContent: 'center',
margin: 'auto',
top: '0',
bottom: '0',
width: '1.0625rem',
height: '1.0625rem'
height: '1.0625rem',
'&:hover': {
backgroundColor: 'transparent'
}
});

/**
Expand All @@ -94,6 +92,7 @@ export const inputButtonStyle = mergeStyles({
export const inputButtonContainerStyle = (rtl?: boolean): string =>
mergeStyles({
display: 'flex',
alignItems: 'baseline',
justifyContent: 'center',
position: 'absolute',
margin: 'auto',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const sendBoxStyle = mergeStyles({
* @private
*/
export const sendButtonStyle = mergeStyles({
margin: 'auto .6rem',
paddingBottom: '1.125rem'
margin: '.6rem'
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"editBoxTextLimit": "Your message is over the limit of {limitNumber} characters",
"editBoxPlaceholderText": "Edit your message",
"newMessagesIndicator": "New messages",
"noDisplayNameSub": "No name"
"noDisplayNameSub": "No name",
"editBoxCancelButton": "Cancel",
"editBoxSubmitButton": "Submit"
},
"errorBar": {
"unableToReachChatService": "You are offline",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,49 @@ exports[`storybook snapshot tests Storyshots UI Components/Send Box Send Box 1`]
<div
className="css-4"
>
<div
className="css-64 css-59"
<button
className="ms-Button ms-Button--icon css-64 css-59 root-19"
data-is-focusable={true}
id="sendIconWrapper"
onClick={[Function]}
onKeyDown={[Function]}
onKeyPress={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
type="button"
>
<i
aria-hidden={true}
className="root-37 css-60 root-19"
data-icon-name="SendBoxSend"
<span
className="ms-Button-flexContainer flexContainer-20"
data-automationid="splitbuttonprimary"
>
<span
<i
aria-hidden={true}
className="root-span"
className="root-37 css-60 root-27"
data-icon-name="SendBoxSend"
>
<svg
className="svg"
fill="currentColor"
height={20}
viewBox="0 0 20 20"
width={20}
xmlns="http://www.w3.org/2000/svg"
<span
aria-hidden={true}
className="root-span"
>
<path
d="M2.72 2.05l15.36 7.57a.5.5 0 010 .9L2.72 18.07a.5.5 0 01-.7-.58l1.97-7.43-1.97-7.44a.5.5 0 01.7-.58zm.54 1.38l1.61 6.09.07-.02H12a.5.5 0 01.09 1H5a.5.5 0 01-.1 0l-1.63 6.2 13.45-6.63L3.26 3.43z"
/>
</svg>
</span>
</i>
</div>
<svg
className="svg"
fill="currentColor"
height={20}
viewBox="0 0 20 20"
width={20}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M2.72 2.05l15.36 7.57a.5.5 0 010 .9L2.72 18.07a.5.5 0 01-.7-.58l1.97-7.43-1.97-7.44a.5.5 0 01.7-.58zm.54 1.38l1.61 6.09.07-.02H12a.5.5 0 01.09 1H5a.5.5 0 01-.1 0l-1.63 6.2 13.45-6.63L3.26 3.43z"
/>
</svg>
</span>
</i>
</span>
</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const CustomIconExample: () => JSX.Element = () => (
onTyping={async () => {
return;
}}
styles={{ sendMessageIconContainer: { marginTop: '0.65rem' } }}
onRenderIcon={() => <Icon iconName="AirplaneSolid" />}
/>
</div>
Expand Down