From f1eefd99e6e40621ace005afcb1c08c6a69a744e Mon Sep 17 00:00:00 2001 From: Asaad Mahmood Date: Thu, 9 Jun 2016 23:09:35 +0500 Subject: PLT-3094 - Fixing autocomplete and image modal scrolling on mobile (#3279) --- webapp/components/suggestion/suggestion_box.jsx | 9 +++++++-- webapp/components/suggestion/suggestion_list.jsx | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'webapp/components') diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx index 6260e179c..2184b9fab 100644 --- a/webapp/components/suggestion/suggestion_box.jsx +++ b/webapp/components/suggestion/suggestion_box.jsx @@ -31,7 +31,7 @@ export default class SuggestionBox extends React.Component { } componentDidMount() { - $(document).on('click', this.handleDocumentClick); + $(document).on('click touchstart', this.handleDocumentClick); SuggestionStore.addCompleteWordListener(this.suggestionId, this.handleCompleteWord); SuggestionStore.addPretextChangedListener(this.suggestionId, this.handlePretextChanged); @@ -42,7 +42,7 @@ export default class SuggestionBox extends React.Component { SuggestionStore.removePretextChangedListener(this.suggestionId, this.handlePretextChanged); SuggestionStore.unregisterSuggestionBox(this.suggestionId); - $(document).off('click', this.handleDocumentClick); + $(document).off('click touchstart', this.handleDocumentClick); } getTextbox() { @@ -58,6 +58,11 @@ export default class SuggestionBox extends React.Component { handleDocumentClick(e) { const container = $(ReactDOM.findDOMNode(this)); + if ($('.suggestion-list__content').length) { + if (!($(e.target).hasClass('suggestion-list__content') || $(e.target).parents().hasClass('suggestion-list__content'))) { + $('body').removeClass('modal-open'); + } + } if (!(container.is(e.target) || container.has(e.target).length > 0)) { // we can't just use blur for this because it fires and hides the children before // their click handlers can be called diff --git a/webapp/components/suggestion/suggestion_list.jsx b/webapp/components/suggestion/suggestion_list.jsx index 134e7a8d4..f1cccf8aa 100644 --- a/webapp/components/suggestion/suggestion_list.jsx +++ b/webapp/components/suggestion/suggestion_list.jsx @@ -51,6 +51,7 @@ export default class SuggestionList extends React.Component { } getContent() { + $('body').addClass('modal-open'); return $(ReactDOM.findDOMNode(this.refs.content)); } -- cgit v1.2.3-1-g7c22