Expand compose form clickable area

This commit is contained in:
Alex Gleason 2020-04-15 15:21:53 -05:00
parent a82212cdca
commit 21789858c0
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 20 additions and 4 deletions

View file

@ -77,6 +77,7 @@ class ComposeForm extends ImmutablePureComponent {
autoFocus: PropTypes.bool,
group: ImmutablePropTypes.map,
isModalOpen: PropTypes.bool,
clickableAreaRef: PropTypes.object,
};
static defaultProps = {
@ -99,9 +100,15 @@ class ComposeForm extends ImmutablePureComponent {
}
}
getClickableArea = () => {
const { clickableAreaRef } = this.props;
return clickableAreaRef ? clickableAreaRef.current : this.form;
}
handleClick = (e) => {
if (!this.form) return;
if (!this.form.contains(e.target)) {
const clickableArea = this.getClickableArea();
if (!clickableArea) return;
if (!clickableArea.contains(e.target)) {
this.handleClickOutside();
}
}

View file

@ -22,6 +22,11 @@ const mapStateToProps = state => {
export default @connect(mapStateToProps)
class HomePage extends ImmutablePureComponent {
constructor(props) {
super(props);
this.composeBlock = React.createRef();
}
render() {
const { children, account, hasPatron } = this.props;
@ -41,11 +46,15 @@ class HomePage extends ImmutablePureComponent {
<div className='columns-area__panels__main'>
<div className='columns-area columns-area--mobile'>
<div className='timeline-compose-block'>
<div className='timeline-compose-block' ref={this.composeBlock}>
<div className='timeline-compose-block__avatar'>
<Avatar account={account} size={46} />
</div>
<ComposeFormContainer shouldCondense autoFocus={false} />
<ComposeFormContainer
shouldCondense
autoFocus={false}
clickableAreaRef={this.composeBlock}
/>
</div>
{children}