Skip to content
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

Apply PR requests to EuiBottomBar #38

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 3 additions & 18 deletions src-docs/src/views/bottom_bar/bottom_bar_displacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,9 @@ export default () => {
onChange={(id) => onChange(id)}
/>

{toggleIdSelected === 'bottomBarStandard' && (
<EuiBottomBar>
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
onClick={() => setToggleIdSelected(null)}
color="ghost"
size="s"
iconType="cross">
close
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiBottomBar>
)}

{toggleIdSelected === 'bottomBarWithoutAffordForDisplacement' && (
<EuiBottomBar affordForDisplacement={false}>
{toggleIdSelected && (
<EuiBottomBar
affordForDisplacement={toggleIdSelected === 'bottomBarStandard'}>
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
Expand Down
28 changes: 24 additions & 4 deletions src/components/bottom_bar/bottom_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,30 @@ export class EuiBottomBar extends Component<Props> {
}
}

componentWillUnmount() {
if (this.props.affordForDisplacement) {
document.body.style.paddingBottom = '';
componentDidUpdate(prevProps: Props) {
if (prevProps.affordForDisplacement !== this.props.affordForDisplacement) {
if (this.props.affordForDisplacement) {
// start affording for displacement
const height = this.bar ? this.bar.clientHeight : -1;
document.body.style.paddingBottom = `${height}px`;
} else {
// stop affording for displacement
document.body.style.paddingBottom = '';
}
}

if (prevProps.bodyClassName !== this.props.bodyClassName) {
if (prevProps.bodyClassName) {
document.body.classList.remove(prevProps.bodyClassName);
}
if (this.props.bodyClassName) {
document.body.classList.add(this.props.bodyClassName);
}
}
}

componentWillUnmount() {
document.body.style.paddingBottom = '';
Copy link
Owner

Choose a reason for hiding this comment

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

Can this be under an if for if this.props.affordForDisplacement is true so in case the consumer had set it to false because they have a special padding they're adding to the body element they don't want ovreridden.

Copy link
Author

Choose a reason for hiding this comment

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

Good thinking, done!

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks!!!


if (this.props.bodyClassName) {
document.body.classList.remove(this.props.bodyClassName);
Expand All @@ -95,7 +115,7 @@ export class EuiBottomBar extends Component<Props> {
paddingSize,
bodyClassName,
landmarkHeading,
affordForDisplacement, // eslint-disable-line no-unused-vars
affordForDisplacement,
...rest
} = this.props;

Expand Down