diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 792c9d5a6e..f9b7103d63 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -606,9 +606,9 @@ gtk_list_view_size_allocate (GtkWidget *widget,
}
/* step 1: determine width of the list */
- gtk_widget_measure (widget, opposite_orientation,
- -1,
- &min, &nat, NULL, NULL);
+ gtk_list_view_measure_across (widget, opposite_orientation,
+ -1,
+ &min, &nat);
self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height;
if (opposite_scroll_policy == GTK_SCROLL_MINIMUM)
self->list_width = MAX (min, self->list_width);
diff --git a/testsuite/reftests/listview-margin.css b/testsuite/reftests/listview-margin.css
new file mode 100644
index 0000000000..8de8d97250
--- /dev/null
+++ b/testsuite/reftests/listview-margin.css
@@ -0,0 +1,8 @@
+listview, box {
+ margin: 50px;
+ padding: 50px;
+}
+
+row {
+ all: unset;
+}
diff --git a/testsuite/reftests/listview-margin.ref.ui b/testsuite/reftests/listview-margin.ref.ui
new file mode 100644
index 0000000000..c551b8bb76
--- /dev/null
+++ b/testsuite/reftests/listview-margin.ref.ui
@@ -0,0 +1,32 @@
+
+
+
+
diff --git a/testsuite/reftests/listview-margin.ui b/testsuite/reftests/listview-margin.ui
new file mode 100644
index 0000000000..e72a1e5fec
--- /dev/null
+++ b/testsuite/reftests/listview-margin.ui
@@ -0,0 +1,44 @@
+
+
+
+ 0
+
+
+
+
+
+
+
+ - One
+ - Two
+ - Three
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+ GtkListItem
+
+
+
+
+
+
+ ]]>
+
+
+
+
+
+
diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build
index b8e0ef0e64..1cc8a4302c 100644
--- a/testsuite/reftests/meson.build
+++ b/testsuite/reftests/meson.build
@@ -446,6 +446,9 @@ testdata = [
'link-coloring.css',
'link-coloring.ref.ui',
'link-coloring.ui',
+ 'listview-margin.css',
+ 'listview-margin.ref.ui',
+ 'listview-margin.ui',
'listview-with-wrapped-labels.ref.ui',
'listview-with-wrapped-labels.ui',
'marble.xpm',