Skip to content

Commit

Permalink
fix: correct fragment-request listener when filename is null
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-godoy authored and paodb committed Jul 2, 2024
1 parent fb66ae1 commit 18c97dd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.Tabs;
import elemental.json.JsonValue;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -26,8 +27,9 @@ public MultiSourceCodeViewer(List<SourceCodeTab> sourceCodeTabs, Map<String, Str
selectedTab = tabs.getSelectedTab();

getElement().addEventListener("fragment-request", ev -> {
String filename = ev.getEventData().get("event.detail.filename").asString();
findTabWithFilename(filename).ifPresent(tab -> {
JsonValue filename = ev.getEventData().get("event.detail.filename");
findTabWithFilename(Optional.ofNullable(filename).map(JsonValue::asString).orElse(null))
.ifPresent(tab -> {
tabs.setSelectedTab(tab);
});
}).addEventData("event.detail.filename");
Expand Down

0 comments on commit 18c97dd

Please sign in to comment.