Skip to content

Commit

Permalink
Merge branch 'master' into fix/ts-export
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored Aug 9, 2021
2 parents b253fdd + e9ce3da commit cfabbdc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ class Portal extends Component {
close = (e) => {
debug('close()')

_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
this.setState({ open: false })
_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
}

closeWithTimeout = (e, delay) => {
Expand Down
8 changes: 4 additions & 4 deletions src/modules/Dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ export interface StrictDropdownProps {
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props and the new item's value.
*/
onAddItem?: (event: React.KeyboardEvent<HTMLElement>, data: DropdownProps) => void
onAddItem?: (event: React.SyntheticEvent<HTMLElement>, data: DropdownProps) => void

/**
* Called on blur.
*
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onBlur?: (event: React.KeyboardEvent<HTMLElement>, data: DropdownProps) => void
onBlur?: (event: React.FocusEvent<HTMLElement>, data: DropdownProps) => void

/**
* Called when the user attempts to change the value.
Expand All @@ -151,7 +151,7 @@ export interface StrictDropdownProps {
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onClick?: (event: React.KeyboardEvent<HTMLElement>, data: DropdownProps) => void
onClick?: (event: React.MouseEvent<HTMLElement>, data: DropdownProps) => void

/**
* Called when a close event happens.
Expand All @@ -167,7 +167,7 @@ export interface StrictDropdownProps {
* @param {SyntheticEvent} event - React's original SyntheticEvent.
* @param {object} data - All props.
*/
onFocus?: (event: React.SyntheticEvent<HTMLElement>, data: DropdownProps) => void
onFocus?: (event: React.FocusEvent<HTMLElement>, data: DropdownProps) => void

/**
* Called when a multi-select label is clicked.
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Modal extends Component {
handleClose = (e) => {
debug('close()')

_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
this.setState({ open: false })
_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
}

handleDocumentMouseDown = (e) => {
Expand All @@ -80,8 +80,8 @@ class Modal extends Component {
)
return

_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
this.setState({ open: false })
_.invoke(this.props, 'onClose', e, { ...this.props, open: false })
}

handleIconOverrides = (predefinedProps) => ({
Expand Down
19 changes: 19 additions & 0 deletions test/specs/modules/Modal/Modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,25 @@ describe('Modal', () => {
domEvent.click(document.body)
onClose.should.not.have.been.called()
})

it('handles unmount without errors', () => {
function ControlledExample() {
const [open, setState] = React.useState(true)

return (
<>
{open && <Modal open onClose={() => setState(false)} />}
<button id='close-button' />
</>
)
}

wrapperMount(<ControlledExample />)
assertBodyContains('.ui.modal')

domEvent.keyDown(document, { key: 'Escape' })
assertBodyContains('.ui.modal', false)
})
})

describe('closeOnEscape', () => {
Expand Down

0 comments on commit cfabbdc

Please sign in to comment.