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

fix(ChatMessage): Author element should always be rendered #761

Merged
merged 8 commits into from
Jan 24, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix teams theme `Status` and `Chat.Message` styles ([#747](https://github.com/stardust-ui/react/pull/747))
- Fix `Popup` - do not stop event propagation when pressing Esc on trigger element @sophieH29 ([#750](https://github.com/stardust-ui/react/pull/750))
- Fix alignment of `Layout`'s `main` area @kuzhelov ([#752](https://github.com/stardust-ui/react/pull/752))
- Fix `ChatMessage` - Author element should always be rendered @sophieH29 ([#761](https://github.com/stardust-ui/react/pull/761))

### Features
- Rename `Slot` component to `Box` and export it @Bugaa92 ([#713](https://github.com/stardust-ui/react/pull/713))
Expand Down
5 changes: 2 additions & 3 deletions src/components/Chat/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
unhandledProps,
styles,
}: RenderResultConfig<ChatMessageProps>) {
const { author, children, content, mine, timestamp } = this.props
const { author, children, content, timestamp } = this.props
const childrenPropExists = childrenExist(children)
const className = childrenPropExists ? cx(classes.root, classes.content) : classes.root

Expand All @@ -119,8 +119,7 @@ class ChatMessage extends UIComponent<ReactProps<ChatMessageProps>, ChatMessageS
children
) : (
<>
{!mine &&
Text.create(author, { defaultProps: { size: 'small', styles: styles.author } })}
{Text.create(author, { defaultProps: { size: 'small', styles: styles.author } })}
{Text.create(timestamp, {
defaultProps: { size: 'small', styles: styles.timestamp, timestamp: true },
})}
Expand Down
12 changes: 2 additions & 10 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import DropdownItem from './DropdownItem'
import DropdownSelectedItem, { DropdownSelectedItemProps } from './DropdownSelectedItem'
import DropdownSearchInput, { DropdownSearchInputProps } from './DropdownSearchInput'
import Button from '../Button/Button'
import { screenReaderContainerStyles } from '../../lib/accessibility/Styles/accessibilityStyles'

// TODO: To be replaced when Downshift will add highlightedItem in their interface.
export interface A11yStatusMessageOptions<Item> extends DownshiftA11yStatusMessageOptions<Item> {
Expand Down Expand Up @@ -554,16 +555,7 @@ export default class Dropdown extends AutoControlledComponent<
statusDiv.setAttribute('role', 'status')
statusDiv.setAttribute('aria-live', 'polite')
statusDiv.setAttribute('aria-relevant', 'additions text')
Object.assign(statusDiv.style, {
border: '0',
clip: 'rect(0 0 0 0)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
padding: '0',
position: 'absolute',
width: '1px',
})
Object.assign(statusDiv.style, screenReaderContainerStyles)
document.body.appendChild(statusDiv)
}

Expand Down
13 changes: 13 additions & 0 deletions src/lib/accessibility/Styles/accessibilityStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Visually hides elements which remain visible for screen reader
import { ICSSInJSStyle } from '../../../themes/types'

export const screenReaderContainerStyles: ICSSInJSStyle = {
border: '0',
clip: 'rect(0 0 0 0)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
padding: '0',
position: 'absolute',
width: '1px',
}
3 changes: 2 additions & 1 deletion src/themes/teams/components/Chat/chatMessageStyles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ComponentSlotStylesInput, ICSSInJSStyle } from '../../../types'
import { ChatMessageProps } from '../../../../components/Chat/ChatMessage'
import { ChatMessageVariables } from './chatMessageVariables'
import { screenReaderContainerStyles } from '../../../../lib/accessibility/Styles/accessibilityStyles'

const chatMessageStyles: ComponentSlotStylesInput<ChatMessageProps, ChatMessageVariables> = {
root: ({ props: p, variables: v }): ICSSInJSStyle => ({
Expand All @@ -23,8 +24,8 @@ const chatMessageStyles: ComponentSlotStylesInput<ChatMessageProps, ChatMessageV
}),

author: ({ props: p, variables: v }): ICSSInJSStyle => ({
display: p.mine ? 'none' : undefined,
marginRight: v.authorMargin,
...(p.mine && screenReaderContainerStyles),
}),

content: ({ variables: v }): ICSSInJSStyle => ({
Expand Down