Skip to content

Commit

Permalink
content/msglist: Fix vertical position of horizontal scrollbar in cod…
Browse files Browse the repository at this point in the history
…eblock

Discussion of this solution:
  zulip#736 (comment)

Fixes: zulip#736
  • Loading branch information
chrisbobbe committed Jun 17, 2024
1 parent d67be76 commit 543c960
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
final length = model!.items.length;
const centerSliverKey = ValueKey('center sliver');

final sliver = SliverStickyHeaderList(
Widget sliver = SliverStickyHeaderList(
headerPlacement: HeaderPlacement.scrollingStart,
delegate: SliverChildBuilderDelegate(
// To preserve state across rebuilds for individual [MessageItem]
Expand Down Expand Up @@ -335,6 +335,12 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
return _buildItem(data, i);
}));

if (widget.narrow is CombinedFeedNarrow) {
// TODO(#311) If we have a bottom nav, it will pad the bottom
// inset, and this shouldn't be necessary
sliver = SliverSafeArea(sliver: sliver);
}

return CustomScrollView(
// TODO: Offer `ScrollViewKeyboardDismissBehavior.interactive` (or
// similar) if that is ever offered:
Expand Down
16 changes: 16 additions & 0 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ void main() {
return scrollView.controller;
}

group('presents message content appropriately', () {
// regression test for https://github.com/zulip/zulip-flutter/issues/736
testWidgets('content in "Combined feed" not asked to consume insets (including bottom)', (tester) async {
const fakePadding = FakeViewPadding(left: 10, top: 10, right: 10, bottom: 10);
tester.view.viewInsets = fakePadding;
tester.view.padding = fakePadding;

await setupMessageListPage(tester, narrow: const CombinedFeedNarrow(),
messages: [eg.streamMessage(content: ContentExample.codeBlockPlain.html)]);

final element = tester.element(find.byType(CodeBlock));
final padding = MediaQuery.of(element).padding;
check(padding).equals(EdgeInsets.zero);
});
});

group('fetch older messages on scroll', () {
int? itemCount(WidgetTester tester) =>
tester.widget<CustomScrollView>(find.byType(CustomScrollView)).semanticChildCount;
Expand Down

0 comments on commit 543c960

Please sign in to comment.