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 committed Jun 26, 2024
1 parent f0a4365 commit 6dc63a1
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 6dc63a1

Please sign in to comment.