From 816bc36ec6c1f7e3427704108b6dbc0d5ba51c9d Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Fri, 26 Jul 2024 17:44:26 +0300 Subject: [PATCH] fix #947 Calling SetTitle twice on NavBar removes description --- .../dominokit/domino/ui/layout/NavBar.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/layout/NavBar.java b/domino-ui/src/main/java/org/dominokit/domino/ui/layout/NavBar.java index 0ff40e737..51abfd14c 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/layout/NavBar.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/layout/NavBar.java @@ -24,6 +24,7 @@ import org.dominokit.domino.ui.elements.HeadingElement; import org.dominokit.domino.ui.elements.NavElement; import org.dominokit.domino.ui.elements.SmallElement; +import org.dominokit.domino.ui.elements.SpanElement; import org.dominokit.domino.ui.utils.*; /** @@ -57,6 +58,7 @@ public class NavBar extends BaseDominoElement { private NavElement root; private HeadingElement title; + private SpanElement titleTextElement; private LazyChild description; private DivElement body; @@ -84,7 +86,7 @@ public NavBar() { root = nav() .addCss(dui_nav_bar) - .appendChild(title = h(4).addCss(dui_nav_title)) + .appendChild(title = h(4).appendChild(titleTextElement = span()).addCss(dui_nav_title)) .appendChild(body = div().addCss(dui_nav_body)); description = LazyChild.of(small().addCss(dui_nav_description), title); init(this); @@ -118,7 +120,7 @@ public NavBar(String title, String description) { * @return This {@code NavBar} instance. */ public NavBar setTitle(String title) { - this.title.setTextContent(title); + this.titleTextElement.setTextContent(title); return this; } @@ -159,6 +161,17 @@ public NavBar withDescription(ChildHandler handler) { return this; } + /** + * Allows customization of the title text element. + * + * @param handler The handler for customizing the title text element. + * @return This {@code NavBar} instance. + */ + public NavBar withTitleTextElement(ChildHandler handler) { + handler.apply(this, titleTextElement); + return this; + } + /** * Gets the title element. * @@ -186,6 +199,11 @@ public String getTitle() { return title.getTextContent(); } + /** @return the element containing the text of the title. */ + public SpanElement getTitleTextElement() { + return titleTextElement; + } + /** * Gets the text of the description displayed in the navigation bar. *