-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give close button on flyout a data-test-subj #1000
Changes from 3 commits
48b0af1
389a934
df10dc5
0f63bb5
da100cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
import React, { Component } from 'react'; | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import FocusTrap from 'focus-trap-react'; | ||
|
@@ -28,21 +26,9 @@ export class EuiFlyout extends Component { | |
}; | ||
|
||
render() { | ||
const { | ||
className, | ||
children, | ||
hideCloseButton, | ||
onClose, | ||
ownFocus, | ||
size, | ||
...rest | ||
} = this.props; | ||
const { className, children, hideCloseButton, onClose, ownFocus, size, ...rest } = this.props; | ||
|
||
const classes = classnames( | ||
'euiFlyout', | ||
sizeToClassNameMap[size], | ||
className | ||
); | ||
const classes = classnames('euiFlyout', sizeToClassNameMap[size], className); | ||
|
||
let closeButton; | ||
if (onClose && !hideCloseButton) { | ||
|
@@ -53,14 +39,17 @@ export class EuiFlyout extends Component { | |
color="text" | ||
aria-label="Closes this dialog" | ||
onClick={onClose} | ||
data-test-subj="euiFlyoutCloseButton" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something that can be passed down via My worry with hard-coding this value is if there are multiple flyouts on the page, it might not know which close button is being targeted and so you could get a false pass. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that's a downside. We could do that too. I don't feel strongly either way, though if we do go that route, we could put onClose in that too (but then it should be onClick) closeButtonProps = { onClick, data-test-subj, aria-label }. I'm game with either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the kind of situation where it makes sense to hard-code the |
||
/> | ||
); | ||
} | ||
|
||
const flyoutContent = ( | ||
<div | ||
role="dialog" | ||
ref={node => { this.flyout = node; }} | ||
ref={node => { | ||
this.flyout = node; | ||
}} | ||
className={classes} | ||
tabIndex={0} | ||
onKeyDown={this.onKeyDown} | ||
|
@@ -75,9 +64,7 @@ export class EuiFlyout extends Component { | |
// to click it to close it. | ||
let optionalOverlay; | ||
if (ownFocus) { | ||
optionalOverlay = ( | ||
<EuiOverlayMask onClick={onClose} /> | ||
); | ||
optionalOverlay = <EuiOverlayMask onClick={onClose} />; | ||
} | ||
|
||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this to:
for consistency?