Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix Attachment `styles` prop typing @levithomason ([#299](https://github.com/stardust-ui/react/pull/299))
- Fix generation of `key` for the `Accordion.Content` @mnajdova ([#305](https://github.com/stardust-ui/react/pull/305))
- Ensure `Popup` is rendered as direct child of `body` element in the DOM tree @kuzhelov ([#302](https://github.com/stardust-ui/react/pull/302))
- Fix toggle logic of `Popup` as reaction on key press events @kuzhelov ([#304](https://github.com/stardust-ui/react/pull/304))

### Features
- Add focus styles for `Menu.Item` component @Bugaa92 ([#286](https://github.com/stardust-ui/react/pull/286))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Button, Popup } from '@stardust-ui/react'
import { Button, Input, Popup } from '@stardust-ui/react'

class PopupExample extends React.Component<any, any> {
state = { popupOpen: false }
Expand All @@ -13,11 +13,11 @@ class PopupExample extends React.Component<any, any> {
<Popup
open={this.state.popupOpen}
onOpenChange={(e, newProps) => {
alert(`Popup is requested to change its open state to "${newProps.open}".`)
this.setState({ popupOpen: newProps.open })
alert(`Popup open state was changed to "${newProps.open ? 'true' : 'false'}".`)
}}
trigger={<Button icon="expand" onClick={() => this.togglePopup()} />}
content="Add users to your feed."
content={<Input icon="search" placeholder="Search..." />}
/>
)
}
Expand Down
14 changes: 6 additions & 8 deletions docs/src/examples/components/Popup/Types/PopupExample.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Button, Popup } from '@stardust-ui/react'
import { Button, Input, Popup } from '@stardust-ui/react'

class PopupExample extends React.Component<any, any> {
state = { popupOpen: false }
Expand All @@ -8,17 +8,15 @@ class PopupExample extends React.Component<any, any> {
this.setState(prev => ({ popupOpen: !prev.popupOpen }))
}

handleOpenChange = (e, newProps) => {
this.setState({ popupOpen: newProps.open })
alert(`Popup open state was changed to "${newProps.open ? 'true' : 'false'}".`)
}

render() {
return (
<Popup
open={this.state.popupOpen}
onOpenChange={this.handleOpenChange.bind(this)}
content="Add users to your feed."
onOpenChange={(e, newProps) => {
alert(`Popup is requested to change its open state to "${newProps.open}".`)
this.setState({ popupOpen: newProps.open })
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for simplicity :)

content={<Input icon="search" placeholder="Search..." />}
>
<Button icon="expand" onClick={() => this.togglePopup()} />
</Popup>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/components/Popup/Types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Types = () => (
<ExampleSection title="Types">
<ComponentExample
title="Default"
description="A default popup. Note that Popup is a controlled component, and its 'open' prop value could be changed either by parent component, or by user actions (keypress) - thus it is necessary to handle 'onOpenChanged' event. Try to press space key while button is focused to see the effect."
description="A default popup. Note that Popup is a controlled component, and its 'open' prop value could be changed either by parent component, or by user actions (e.g. key press) - thus it is necessary to handle 'onOpenChanged' event. Try to type some text into popup's input field and press ESC to see the effect."
Copy link
Contributor

Choose a reason for hiding this comment

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

like it!

examplePath="components/Popup/Types/PopupExample"
/>
</ExampleSection>
Expand Down
5 changes: 0 additions & 5 deletions src/lib/accessibility/Behaviors/Popup/PopupBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ const PopupBehavior: Accessibility = (props: any) => ({
},
},
keyActions: {
trigger: {
toggle: {
keyCombinations: [{ keyCode: keyboardKey.Enter }, { keyCode: keyboardKey.Spacebar }],
},
},
popup: {
closeAndFocusTrigger: {
keyCombinations: [{ keyCode: keyboardKey.Escape }],
Expand Down