Skip to content

Commit 530a0d6

Browse files
mihai-dinculesculayershifter
authored andcommitted
fix(Modal): remove dimmer={false} (Semantic-Org#2882)
* docs(Modal): Fix multiple and close examples * fix(Modal): remove useless tests and update propTypes Signed-off-by: Oleksandr Fediashov <[email protected]> * Update TS def.
1 parent 8a26279 commit 530a0d6

File tree

6 files changed

+19
-36
lines changed

6 files changed

+19
-36
lines changed

docs/src/examples/modules/Modal/Types/ModalExampleMultiple.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class NestedModal extends Component {
1212

1313
return (
1414
<Modal
15-
dimmer={false}
1615
open={open}
1716
onOpen={this.open}
1817
onClose={this.close}

docs/src/examples/modules/Modal/Variations/ModalExampleCloseConfig.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ class ModalExampleCloseConfig extends Component {
2222
open={open}
2323
closeOnEscape={closeOnEscape}
2424
closeOnRootNodeClick={closeOnRootNodeClick}
25-
onClose={this.close}
2625
>
2726
<Modal.Header>Delete Your Account</Modal.Header>
2827
<Modal.Content>
2928
<p>Are you sure you want to delete your account</p>
3029
</Modal.Content>
3130
<Modal.Actions>
32-
<Button negative>No</Button>
33-
<Button positive labelPosition='right' icon='checkmark' content='Yes' />
31+
<Button onClick={this.close} negative>
32+
No
33+
</Button>
34+
<Button
35+
onClick={this.close}
36+
positive
37+
labelPosition='right'
38+
icon='checkmark'
39+
content='Yes'
40+
/>
3441
</Modal.Actions>
3542
</Modal>
3643
</div>

docs/src/examples/modules/Modal/Variations/ModalExampleDimmer.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react'
2-
import { Popup, Button, Header, Image, Modal } from 'semantic-ui-react'
2+
import { Button, Header, Image, Modal } from 'semantic-ui-react'
33

44
class ModalExampleDimmer extends Component {
55
state = { open: false }
@@ -15,15 +15,6 @@ class ModalExampleDimmer extends Component {
1515
<Button onClick={this.show(true)}>Default</Button>
1616
<Button onClick={this.show('inverted')}>Inverted</Button>
1717
<Button onClick={this.show('blurring')}>Blurring</Button>
18-
<Popup trigger={<Button onClick={this.show(false)}>None</Button>}>
19-
<Popup.Header>Heads up!</Popup.Header>
20-
<Popup.Content>
21-
By default, a Modal closes when escape is pressed or when the dimmer is clicked. Setting
22-
the dimmer to "None" (dimmer={'{'}false{'}'}) means that there is no dimmer to click so
23-
clicking outside won't close the Modal. To close on outside click when there's no
24-
dimmer, you can pass the "closeOnDocumentClick" prop.
25-
</Popup.Content>
26-
</Popup>
2718

2819
<Modal dimmer={dimmer} open={open} onClose={this.close}>
2920
<Modal.Header>Select a Photo</Modal.Header>

src/modules/Modal/Modal.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface ModalProps extends PortalProps {
4444
defaultOpen?: boolean;
4545

4646
/** A modal can appear in a dimmer. */
47-
dimmer?: boolean | 'blurring' | 'inverted';
47+
dimmer?: true | 'blurring' | 'inverted';
4848

4949
/** Event pool namespace that is used to handle component events */
5050
eventPool?: string;

src/modules/Modal/Modal.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Modal extends Component {
6565
defaultOpen: PropTypes.bool,
6666

6767
/** A Modal can appear in a dimmer. */
68-
dimmer: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['inverted', 'blurring'])]),
68+
dimmer: PropTypes.oneOf([true, 'inverted', 'blurring']),
6969

7070
/** Event pool namespace that is used to handle component events */
7171
eventPool: PropTypes.string,
@@ -348,14 +348,12 @@ class Modal extends Component {
348348
const portalProps = _.pick(unhandled, portalPropNames)
349349

350350
// wrap dimmer modals
351-
const dimmerClasses = !dimmer
352-
? null
353-
: cx(
354-
'ui',
355-
dimmer === 'inverted' && 'inverted',
356-
!centered && 'top aligned',
357-
'page modals dimmer transition visible active',
358-
)
351+
const dimmerClasses = cx(
352+
'ui',
353+
dimmer === 'inverted' && 'inverted',
354+
!centered && 'top aligned',
355+
'page modals dimmer transition visible active',
356+
)
359357

360358
// Heads up!
361359
//

test/specs/modules/Modal/Modal-test.js

-12
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,6 @@ describe('Modal', () => {
249249
})
250250
})
251251

252-
describe('false', () => {
253-
it('does not render a dimmer', () => {
254-
wrapperMount(<Modal open dimmer={false} />)
255-
assertBodyClasses('dimmable dimmed blurring', false)
256-
})
257-
258-
it('does not add any dimmer classes to the body', () => {
259-
wrapperMount(<Modal open dimmer={false} />)
260-
assertBodyClasses('dimmable dimmed blurring', false)
261-
})
262-
})
263-
264252
describe('blurring', () => {
265253
it('adds/removes body classes "dimmable dimmed blurring" on mount/unmount', () => {
266254
assertBodyClasses('dimmable dimmed blurring', false)

0 commit comments

Comments
 (0)