diff --git a/docs/state.md b/docs/state.md
index 03131061666..668afcdff03 100644
--- a/docs/state.md
+++ b/docs/state.md
@@ -277,7 +277,8 @@ WindowStore
searchString: string, // the string being searched
caseSensitivity: boolean, // whether we are doing a case sensitive search
numberOfMatches: number, // Total number of matches on the page
- activeMatchOrdinal: number // The current ordinal of the match
+ activeMatchOrdinal: number, // The current ordinal of the match
+ internalFindStatePresent: boolean // true if a find-first (ie findNext: false) call has been made
}
unloaded: boolean, // true if the tab is unloaded
diff --git a/js/actions/webviewActions.js b/js/actions/webviewActions.js
index b5617c4dab4..0ae2afa74df 100644
--- a/js/actions/webviewActions.js
+++ b/js/actions/webviewActions.js
@@ -81,6 +81,31 @@ const webviewActions = {
webview.executeJavaScript('document.webkitRequestFullscreen()')
}
}
+ },
+
+ findInPage: function (searchString, caseSensitivity, forward, findNext, webview) {
+ webview = webview || getWebview()
+ if (!webview) {
+ return
+ }
+
+ if (searchString) {
+ webview.findInPage(searchString, {
+ matchCase: caseSensitivity,
+ forward,
+ findNext
+ })
+ } else {
+ webview.stopFindInPage('clearSelection')
+ }
+ },
+
+ stopFindInPage: function (webview) {
+ webview = webview || getWebview()
+ if (!webview) {
+ return
+ }
+ webview.stopFindInPage('keepSelection')
}
}
diff --git a/js/components/button.js b/js/components/button.js
index e756fbf9b0c..bd9c2e7974e 100644
--- a/js/components/button.js
+++ b/js/components/button.js
@@ -11,6 +11,7 @@ class Button extends ImmutableComponent {
if (this.props.iconClass) {
return
}
- return
-
- { this.searchInput = node }}
- onKeyDown={this.onKeyDown}
- onChange={this.onChange}
- value={this.searchString} />
- {findMatchText}
-
-
-
-
-
-
+
+
+
+ { this.searchInput = node }}
+ onKeyDown={this.onKeyDown}
+ onChange={this.onChange}
+ value={this.searchString} />
+
+
+
{findMatchText}
+
+
+
-
+ checkedOn={this.isCaseSensitive}
+ onClick={this.onCaseSensitivityChange} />
+
+
+
}
}
diff --git a/js/components/frame.js b/js/components/frame.js
index 401620f7dee..aebd63170e0 100644
--- a/js/components/frame.js
+++ b/js/components/frame.js
@@ -5,6 +5,7 @@
const React = require('react')
const urlParse = require('url').parse
const windowActions = require('../actions/windowActions')
+const webviewActions = require('../actions/webviewActions')
const appActions = require('../actions/appActions')
const ImmutableComponent = require('./immutableComponent')
const Immutable = require('immutable')
@@ -22,7 +23,6 @@ const debounce = require('../lib/debounce.js')
const getSetting = require('../settings').getSetting
const config = require('../constants/config')
const settings = require('../constants/settings')
-const FindBar = require('./findbar.js')
const { aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isNavigatableAboutPage } = require('../lib/appUrlUtil')
const { isFrameError } = require('../lib/errorUtil')
const locale = require('../l10n')
@@ -44,8 +44,6 @@ class Frame extends ImmutableComponent {
constructor () {
super()
this.onUpdateWheelZoom = debounce(this.onUpdateWheelZoom.bind(this), 20)
- this.onFind = this.onFind.bind(this)
- this.onFindHide = this.onFindHide.bind(this)
this.onFocus = this.onFocus.bind(this)
// Maps notification message to its callback
this.notificationCallbacks = {}
@@ -832,7 +830,7 @@ class Frame extends ImmutableComponent {
this.webview.addEventListener('did-navigate', (e) => {
if (this.props.findbarShown) {
- this.onFindHide()
+ windowActions.setFindbarShown(this.frame, false)
}
for (let message in this.notificationCallbacks) {
@@ -993,15 +991,10 @@ class Frame extends ImmutableComponent {
}
const searchString = this.props.findDetail && this.props.findDetail.get('searchString')
if (searchString) {
- this.onFind(searchString, this.props.findDetail && this.props.findDetail.get('caseSensitivity') || undefined, forward)
+ webviewActions.findInPage(searchString, this.props.findDetail && this.props.findDetail.get('caseSensitivity') || undefined, forward, this.props.findDetail.get('internalFindStatePresent'), this.webview)
}
}
- onFindHide () {
- windowActions.setFindbarShown(this.frame, false)
- this.webview.stopFindInPage('keepSelection')
- }
-
onUpdateWheelZoom () {
if (this.wheelDeltaY > 0) {
this.zoomIn()
@@ -1021,22 +1014,6 @@ class Frame extends ImmutableComponent {
}
}
- onFind (searchString, caseSensitivity, forward) {
- if (searchString) {
- this.webview.findInPage(searchString, {
- matchCase: caseSensitivity,
- forward: forward !== undefined ? forward : true,
- findNext: forward !== undefined
- })
- } else {
- this.onClearMatch()
- }
- }
-
- onClearMatch () {
- this.webview.stopFindInPage('clearSelection')
- }
-
get webRTCPolicy () {
return this.webview ? this.webview.getWebRTCIPHandlingPolicy() : WEBRTC_DEFAULT
}
@@ -1062,16 +1039,6 @@ class Frame extends ImmutableComponent {
?
: null
}
- {
- this.props.findbarShown && !this.props.isFullScreen
- ?
- : null
- }
{ this.webviewContainer = node }}
className={cx({
webviewContainer: true,
diff --git a/js/components/main.js b/js/components/main.js
index 704b8c2568b..746a8a6aad3 100644
--- a/js/components/main.js
+++ b/js/components/main.js
@@ -20,6 +20,7 @@ const NavigationBar = require('./navigationBar')
const Frame = require('./frame')
const TabPages = require('./tabPages')
const TabsToolbar = require('./tabsToolbar')
+const FindBar = require('./findbar.js')
const UpdateBar = require('./updateBar')
const NotificationBar = require('./notificationBar')
const DownloadsBar = require('./downloadsBar')
@@ -86,6 +87,8 @@ class Main extends ImmutableComponent {
this.onBraveMenu = this.onBraveMenu.bind(this)
this.onHamburgerMenu = this.onHamburgerMenu.bind(this)
this.onTabContextMenu = this.onTabContextMenu.bind(this)
+ this.onFind = this.onFind.bind(this)
+ this.onFindHide = this.onFindHide.bind(this)
this.checkForTitleMode = debounce(this.checkForTitleMode.bind(this), 20)
}
registerWindowLevelShortcuts () {
@@ -627,6 +630,24 @@ class Main extends ImmutableComponent {
windowActions.setUrlBarActive(false)
}
+ onFindHide () {
+ const activeFrame = FrameStateUtil.getActiveFrame(this.props.windowState)
+ windowActions.setFindbarShown(activeFrame, false)
+ webviewActions.stopFindInPage()
+ windowActions.setFindDetail(this.frame, Immutable.fromJS({
+ internalFindStatePresent: false
+ }))
+ }
+
+ onFind (searchString, caseSensitivity, forward, findNext) {
+ webviewActions.findInPage(searchString, caseSensitivity, forward, findNext)
+ if (!findNext) {
+ windowActions.setFindDetail(this.frame, Immutable.fromJS({
+ internalFindStatePresent: true
+ }))
+ }
+ }
+
onTabContextMenu (e) {
const activeFrame = FrameStateUtil.getActiveFrame(this.props.windowState)
contextMenus.onTabsToolbarContextMenu(activeFrame, undefined, undefined, e)
@@ -901,6 +922,20 @@ class Main extends ImmutableComponent {
activeFrameKey={activeFrame && activeFrame.get('key') || undefined}
onMenu={this.onHamburgerMenu}
/>
+
+ {
+ activeFrame && activeFrame.get('findbarShown') && !activeFrame.get('isFullScreen')
+ ?
+ : null
+ }