Skip to content

Commit

Permalink
Merge pull request #43 from react-component/fix-text-auto-layout
Browse files Browse the repository at this point in the history
fix text auto layout bug
  • Loading branch information
yiminghe committed Feb 27, 2017
2 parents 9edc5af + ba1ccc9 commit 2e4adf7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ const Trigger = React.createClass({
// Make sure default popup container will never cause scrollbar appearing
// https://github.com/react-component/trigger/issues/41
popupContainer.style.position = 'absolute';
popupContainer.style.top = '-9999px';
popupContainer.style.left = '-9999px';
popupContainer.style.top = '0';
popupContainer.style.left = '0';
popupContainer.style.width = '100%';
const mountNode = instance.props.getPopupContainer ?
instance.props.getPopupContainer(findDOMNode(instance)) : document.body;
mountNode.appendChild(popupContainer);
Expand Down
33 changes: 33 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,37 @@ describe('rc-trigger', function main() {
});
});
}

describe('github issues', () => {
// https://github.com/ant-design/ant-design/issues/5047
// https://github.com/react-component/trigger/pull/43
it('render text without break lines', () => {
const trigger = ReactDOM.render(
<Trigger
popupVisible
popupAlign={placementAlignMap.top}
popup={<span>i am a pop up</span>}
popupClassName="no-fix-width"
>
<div>trigger</div>
</Trigger>
, div);
const popupNodeHeightOfSeveralWords = trigger.getPopupDomNode().offsetHeight;

const trigger2 = ReactDOM.render(
<Trigger
popupVisible
popupAlign={placementAlignMap.top}
popup={<span>iamapopup</span>}
popupClassName="no-fix-width"
>
<div>trigger</div>
</Trigger>
, div);
const popupNodeHeightOfOneWord = trigger2.getPopupDomNode().offsetHeight;

// height should be same, should not have break lines inside words
expect(popupNodeHeightOfOneWord).to.equal(popupNodeHeightOfSeveralWords);
});
});
});
4 changes: 4 additions & 0 deletions tests/test.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
width: 100px;
}

.no-fix-width.rc-trigger-popup {
width: auto;
}

.target {
width: 100px;
height: 100px;
Expand Down

0 comments on commit 2e4adf7

Please sign in to comment.