From c423a68cfc20f5bed32cd0879f933d355fcf89c4 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Tue, 27 Jun 2017 17:15:13 -0700 Subject: [PATCH] Update selectedIndex when a new URL is loaded --- src/plugins/topbar/topbar.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/topbar/topbar.jsx b/src/plugins/topbar/topbar.jsx index 1773cdbc..30655b33 100644 --- a/src/plugins/topbar/topbar.jsx +++ b/src/plugins/topbar/topbar.jsx @@ -27,6 +27,7 @@ export default class Topbar extends React.Component { onUrlSelect =(e)=> { let url = e.target.value || e.target.href this.loadSpec(url) + this.setSelectedUrl(url) e.preventDefault() } @@ -35,6 +36,23 @@ export default class Topbar extends React.Component { e.preventDefault() } + setSelectedUrl = (selectedUrl) => { + const configs = this.props.getConfigs() + const urls = configs.urls || [] + + if(urls && urls.length) { + if(selectedUrl) + { + urls.forEach((spec, i) => { + if(spec.url === selectedUrl) + { + this.setState({selectedIndex: i}) + } + }) + } + } + } + componentWillMount() { const configs = this.props.getConfigs() const urls = configs.urls || []