Skip to content

Commit

Permalink
BUGFIX: correctly position toolbar on narrow elements
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaip committed Apr 8, 2018
1 parent 1f5b705 commit 6ed29b0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/neos-ui-guest-frame/src/InlineUI/NodeToolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,28 @@ export default class NodeToolbar extends PureComponent {
const nodeElement = findNodeInGuestFrame(contextPath, fusionPath);
const {top, right} = getAbsolutePositionOfElementInGuestFrame(nodeElement);

// TODO: hardcoded dimensions
const TOOLBAR_WIDTH = 200;
const TOOLBAR_HEIGHT = 50;

const rect = nodeElement.getBoundingClientRect();
const toolbarPosition = {
top: top - TOOLBAR_HEIGHT
};
if (rect.right < TOOLBAR_WIDTH) {
toolbarPosition.left = 0;
} else {
toolbarPosition.right = right;
}

const {isSticky} = this.state;
const classNames = mergeClassNames({
[style.toolBar]: true,
[style['toolBar--isSticky']]: isSticky
});

return (
<div className={classNames} style={{top: top - 50, right}}>
<div className={classNames} style={toolbarPosition}>
<div className={style.toolBar__btnGroup}>
<AddNode {...props}/>
<HideSelectedNode {...props}/>
Expand Down

0 comments on commit 6ed29b0

Please sign in to comment.