Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #169 from matrix-org/vector_600
Browse files Browse the repository at this point in the history
Bug Fix - Chat screen: unexpected scroll up on new sent messages
  • Loading branch information
giomfo authored Sep 12, 2016
2 parents 24fb7c4 + 3a5fa16 commit 11383c9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions MatrixKit/Controllers/MXKRoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -457,19 +457,25 @@ - (void)setKeyboardHeight:(CGFloat)keyboardHeight
_roomInputToolbarContainerBottomConstraint.constant = inputToolbarViewBottomConst;
_bubblesTableViewBottomConstraint.constant = inputToolbarViewBottomConst + _roomInputToolbarContainerHeightConstraint.constant + _roomActivitiesContainerHeightConstraint.constant;

// Force layout immediately to take into account new constraint
[self.view layoutIfNeeded];
// Invalidate the current layout to take into account the new constraints in the next update cycle.
[self.view setNeedsLayout];

// Compute the visible area (tableview + toolbar) at the end of animation
CGFloat visibleArea = self.view.frame.size.height - _bubblesTableView.contentInset.top - keyboardHeight;
// Deduce max height of the message text input by considering the minimum height of the table view.
inputToolbarView.maxHeight = visibleArea - MXKROOMVIEWCONTROLLER_MESSAGES_TABLE_MINIMUM_HEIGHT;

// Scroll the tableview content when a new keyboard is presented (except if an alert is presented).
if (_scrollHistoryToTheBottomOnKeyboardPresentation && !super.keyboardHeight && keyboardHeight && !currentAlert)
// Check conditions before scrolling the tableview content when a new keyboard is presented.
if ((_scrollHistoryToTheBottomOnKeyboardPresentation || [self isBubblesTableScrollViewAtTheBottom]) && !super.keyboardHeight && keyboardHeight && !currentAlert)
{
// Force here the layout update to scroll correctly the table content.
[self.view layoutIfNeeded];
[self scrollBubblesTableViewToBottomAnimated:NO];
}
else
{
[self updateCurrentEventIdAtTableBottom:NO];
}

super.keyboardHeight = keyboardHeight;
}
Expand Down

0 comments on commit 11383c9

Please # to comment.