Skip to content

Commit 5a1ebdb

Browse files
chrisbobbegnprice
authored andcommitted
content/msglist: Fix vertical position of horizontal scrollbar in codeblock
Discussion of this solution: #736 (comment) Fixes: #736
1 parent ec0bc01 commit 5a1ebdb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/widgets/message_list.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
301301
final length = model!.items.length;
302302
const centerSliverKey = ValueKey('center sliver');
303303

304-
final sliver = SliverStickyHeaderList(
304+
Widget sliver = SliverStickyHeaderList(
305305
headerPlacement: HeaderPlacement.scrollingStart,
306306
delegate: SliverChildBuilderDelegate(
307307
// To preserve state across rebuilds for individual [MessageItem]
@@ -337,6 +337,12 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
337337
return _buildItem(data, i);
338338
}));
339339

340+
if (widget.narrow is CombinedFeedNarrow) {
341+
// TODO(#311) If we have a bottom nav, it will pad the bottom
342+
// inset, and this shouldn't be necessary
343+
sliver = SliverSafeArea(sliver: sliver);
344+
}
345+
340346
return CustomScrollView(
341347
// TODO: Offer `ScrollViewKeyboardDismissBehavior.interactive` (or
342348
// similar) if that is ever offered:

test/widgets/message_list_test.dart

+16
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ void main() {
8686
return scrollView.controller;
8787
}
8888

89+
group('presents message content appropriately', () {
90+
// regression test for https://github.com/zulip/zulip-flutter/issues/736
91+
testWidgets('content in "Combined feed" not asked to consume insets (including bottom)', (tester) async {
92+
const fakePadding = FakeViewPadding(left: 10, top: 10, right: 10, bottom: 10);
93+
tester.view.viewInsets = fakePadding;
94+
tester.view.padding = fakePadding;
95+
96+
await setupMessageListPage(tester, narrow: const CombinedFeedNarrow(),
97+
messages: [eg.streamMessage(content: ContentExample.codeBlockPlain.html)]);
98+
99+
final element = tester.element(find.byType(CodeBlock));
100+
final padding = MediaQuery.of(element).padding;
101+
check(padding).equals(EdgeInsets.zero);
102+
});
103+
});
104+
89105
group('fetch older messages on scroll', () {
90106
int? itemCount(WidgetTester tester) =>
91107
tester.widget<CustomScrollView>(find.byType(CustomScrollView)).semanticChildCount;

0 commit comments

Comments
 (0)