diff --git a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow-integration-tests/src/main/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetPage.java b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow-integration-tests/src/main/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetPage.java index 749963a6e5f..d438533ae03 100644 --- a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow-integration-tests/src/main/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetPage.java +++ b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow-integration-tests/src/main/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetPage.java @@ -29,7 +29,7 @@ public DashboardWidgetPage() { DashboardWidget widget1 = new DashboardWidget(); widget1.setTitle("Widget 1"); widget1.setContent(new Div("Some content")); - widget1.setHeader(new Span("Some header")); + widget1.setHeaderComponent(new Span("Some header")); widget1.setId("widget-1"); DashboardWidget widget2 = new DashboardWidget(); @@ -89,7 +89,7 @@ public DashboardWidgetPage() { updateHeaderOfTheFirstWidget.addClickListener(click -> { List widgets = dashboard.getWidgets(); if (!widgets.isEmpty()) { - widgets.get(0).setHeader(new Span("Updated header")); + widgets.get(0).setHeaderComponent(new Span("Updated header")); } }); updateHeaderOfTheFirstWidget.setId("update-header-of-the-first-widget"); @@ -99,7 +99,7 @@ public DashboardWidgetPage() { removeHeaderOfTheFirstWidget.addClickListener(click -> { List widgets = dashboard.getWidgets(); if (!widgets.isEmpty()) { - widgets.get(0).setHeader(null); + widgets.get(0).setHeaderComponent(null); } }); removeHeaderOfTheFirstWidget.setId("remove-header-of-the-first-widget"); diff --git a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/main/java/com/vaadin/flow/component/dashboard/DashboardWidget.java b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/main/java/com/vaadin/flow/component/dashboard/DashboardWidget.java index ec322af916c..d7de4fa9769 100644 --- a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/main/java/com/vaadin/flow/component/dashboard/DashboardWidget.java +++ b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/main/java/com/vaadin/flow/component/dashboard/DashboardWidget.java @@ -134,25 +134,25 @@ public void setContent(Component content) { } /** - * Gets the component in the header slot of this widget. + * Gets the component in the header content slot of this widget. * * @return the header component of this widget, or {@code null} if no header * component has been set */ - public Component getHeader() { - return SlotUtils.getChildInSlot(this, "header"); + public Component getHeaderComponent() { + return SlotUtils.getChildInSlot(this, "header-content"); } /** - * Sets the component in the header slot of this widget, replacing any - * existing header component. + * Sets the component in the header content slot of this widget, replacing + * any existing header component. * * @param header * the component to set, can be {@code null} to remove existing * header component */ - public void setHeader(Component header) { - SlotUtils.setSlot(this, "header", header); + public void setHeaderComponent(Component header) { + SlotUtils.setSlot(this, "header-content", header); } /** diff --git a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/test/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetTest.java b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/test/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetTest.java index f442cae5880..e1bf6a9ebc1 100644 --- a/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/test/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetTest.java +++ b/vaadin-dashboard-flow-parent/vaadin-dashboard-flow/src/test/java/com/vaadin/flow/component/dashboard/tests/DashboardWidgetTest.java @@ -173,41 +173,41 @@ public void setNullContentToNonEmptyWidget_contentIsRemoved() { @Test public void defaultHeaderIsNull() { DashboardWidget widget = new DashboardWidget(); - Assert.assertNull(widget.getHeader()); + Assert.assertNull(widget.getHeaderComponent()); } @Test public void setHeaderToEmptyWidget_correctHeaderIsSet() { Div header = new Div(); DashboardWidget widget = new DashboardWidget(); - widget.setHeader(header); - Assert.assertEquals(header, widget.getHeader()); + widget.setHeaderComponent(header); + Assert.assertEquals(header, widget.getHeaderComponent()); } @Test public void setAnotherHeaderToNonEmptyWidget_correctHeaderIsSet() { DashboardWidget widget = new DashboardWidget(); - widget.setHeader(new Div()); + widget.setHeaderComponent(new Div()); Span newHeader = new Span(); - widget.setHeader(newHeader); - Assert.assertEquals(newHeader, widget.getHeader()); + widget.setHeaderComponent(newHeader); + Assert.assertEquals(newHeader, widget.getHeaderComponent()); } @Test public void setTheSameHeaderToNonEmptyWidget_correctHeaderIsSet() { Div header = new Div(); DashboardWidget widget = new DashboardWidget(); - widget.setHeader(header); - widget.setHeader(header); - Assert.assertEquals(header, widget.getHeader()); + widget.setHeaderComponent(header); + widget.setHeaderComponent(header); + Assert.assertEquals(header, widget.getHeaderComponent()); } @Test public void setNullHeaderToNonEmptyWidget_headerIsRemoved() { DashboardWidget widget = new DashboardWidget(); - widget.setHeader(new Div()); - widget.setHeader(null); - Assert.assertNull(widget.getHeader()); + widget.setHeaderComponent(new Div()); + widget.setHeaderComponent(null); + Assert.assertNull(widget.getHeaderComponent()); } @Test @@ -215,7 +215,7 @@ public void setNullHeaderToWidgetWithContent_contentIsNotRemoved() { Div content = new Div(); DashboardWidget widget = new DashboardWidget(); widget.setContent(content); - widget.setHeader(null); + widget.setHeaderComponent(null); Assert.assertEquals(content, widget.getContent()); } @@ -223,9 +223,9 @@ public void setNullHeaderToWidgetWithContent_contentIsNotRemoved() { public void setNullContentToWidgetWithHeader_headerIsNotRemoved() { Div header = new Div(); DashboardWidget widget = new DashboardWidget(); - widget.setHeader(header); + widget.setHeaderComponent(header); widget.setContent(null); - Assert.assertEquals(header, widget.getHeader()); + Assert.assertEquals(header, widget.getHeaderComponent()); } @Test @@ -234,9 +234,9 @@ public void setHeaderToWidgetWithContent_contentAndHeaderCorrectlyRetrieved() { Span header = new Span(); DashboardWidget widget = new DashboardWidget(); widget.setContent(content); - widget.setHeader(header); + widget.setHeaderComponent(header); Assert.assertEquals(content, widget.getContent()); - Assert.assertEquals(header, widget.getHeader()); + Assert.assertEquals(header, widget.getHeaderComponent()); } @Test @@ -244,10 +244,10 @@ public void setContentToWidgetWithHeader_contentAndHeaderCorrectlyRetrieved() { Div content = new Div(); Span header = new Span(); DashboardWidget widget = new DashboardWidget(); - widget.setHeader(header); + widget.setHeaderComponent(header); widget.setContent(content); Assert.assertEquals(content, widget.getContent()); - Assert.assertEquals(header, widget.getHeader()); + Assert.assertEquals(header, widget.getHeaderComponent()); } @Test diff --git a/vaadin-dashboard-flow-parent/vaadin-dashboard-testbench/src/main/java/com/vaadin/flow/component/dashboard/testbench/DashboardWidgetElement.java b/vaadin-dashboard-flow-parent/vaadin-dashboard-testbench/src/main/java/com/vaadin/flow/component/dashboard/testbench/DashboardWidgetElement.java index 15b5a2f1385..fd38c637280 100644 --- a/vaadin-dashboard-flow-parent/vaadin-dashboard-testbench/src/main/java/com/vaadin/flow/component/dashboard/testbench/DashboardWidgetElement.java +++ b/vaadin-dashboard-flow-parent/vaadin-dashboard-testbench/src/main/java/com/vaadin/flow/component/dashboard/testbench/DashboardWidgetElement.java @@ -67,7 +67,7 @@ public TestBenchElement getContent() { */ public TestBenchElement getHeader() { Object header = executeScript( - "return Array.from(arguments[0].children).filter(child => child.slot === 'header')[0]", + "return Array.from(arguments[0].children).filter(child => child.slot === 'header-content')[0]", this); return header == null ? null : (TestBenchElement) header; }