Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

URL bar updating improvements #8

Merged
merged 5 commits into from
Dec 8, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update url bar during redirects and tab switches
Update the URL bar at load start instead of load end since that is
what most browsers do.
  • Loading branch information
diracdeltas committed Dec 5, 2015
commit 32198f5c55c9a7fa5af02c4b60857dc5e807b9a1
10 changes: 7 additions & 3 deletions js/components/frame.js
Original file line number Diff line number Diff line change
@@ -80,14 +80,18 @@ class Frame extends ImmutableComponent {
this.webview.addEventListener('dom-ready', () => {
console.log('dom is ready')
})
this.webview.addEventListener('did-get-redirect-request', (oldUrl, newUrl) => {
console.log('got redirect', newUrl)
AppActions.setNavBarInput(newUrl)
this.webview.addEventListener('did-get-redirect-request', (event) => {
// Update the url bar for top-level location changes
if (event.isMainFrame) {
console.log('got redirect', event.oldURL, event.newURL)
AppActions.setNavBarInput(event.newURL)
}
})
this.webview.addEventListener('did-start-loading', () => {
console.log('spinner start loading')
AppActions.onWebviewLoadStart(
this.props.frame)
AppActions.setNavBarInput(this.props.frame.get('location'))
})
this.webview.addEventListener('did-stop-loading', () => {
console.log('spinner stop loading')
7 changes: 7 additions & 0 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
@@ -63,6 +63,13 @@ class UrlBar extends ImmutableComponent {
AppActions.setNavBarFocused(true)
}

componentWillReceiveProps (newProps) {
let location = newProps.activeFrameProps.get('location') // TODO: update this during redirects
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the location prop on the frame isn't getting updated during redirects. help fixing this would be appreciated.

test case:

  1. open a new tab
  2. load google.com, which redirects to https://www.google.com/foobar. URL bar is updated correctly to https://www.google.com/foobar.
  3. switch to another tab
  4. switch back to the original tab. the URL bar displays the original URL ('http://google.com') instead of the actual URL in the frame.

if (location !== this.props.activeFrameProps.get('location')) {
AppActions.setNavBarInput(location)
}
}

render () {
return <form
action='#'
4 changes: 0 additions & 4 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
@@ -96,10 +96,6 @@ AppDispatcher.register((action) => {
appStore.emitChange()
break
case AppConstants.APP_WEBVIEW_LOAD_END:
// Only update for the active frame.
if (action.frameProps === appState.getIn(['frames', FrameStateUtil.findIndexForFrameKey(appState.get('frames'), appState.get('activeFrameKey'))])) {
updateNavBarInput(action.location)
}
appState = appState.mergeIn(['frames', FrameStateUtil.getFramePropsIndex(appState.get('frames'), action.frameProps)], {
loading: false
})