Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions frontend/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class Panel extends React.Component {
this.props.getNewSelection(this._bridge);
}

hideHighlight() {
this._store.hideHighlight();
}

sendSelection(id: string) {
if (!this._bridge || (!id && !this._store.selected)) {
return;
Expand Down
16 changes: 12 additions & 4 deletions frontend/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,21 @@ class Store extends EventEmitter {
this.emit('hover');
this._bridge.send('highlight', id);
} else if (this.hovered === id) {
this.hovered = null;
this.emit(id);
this.emit('hover');
this._bridge.send('hideHighlight');
this.hideHighlight();
}
}

hideHighlight() {
this._bridge.send('hideHighlight');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this line do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It sends a message to the agent (living on the page) to hide the highlight

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it, of course. Does anything listen to the emit('hover')?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah -- here's the file used to connect a Highlighter to an Agent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you misread my question?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh yes! I totally did. No, nothing listens for hover at the moment. Would you rather I remove it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either way. (accepted)

if (!this.hovered) {
return;
}
var id = this.hovered;
this.hovered = null;
this.emit(id);
this.emit('hover');
}

selectTop(id: ?ElementID, noHighlight?: boolean) {
this.isBottomTagSelected = false;
this.select(id, noHighlight);
Expand Down
2 changes: 1 addition & 1 deletion shells/chrome/src/GlobalHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var checkForOld = `
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
console.error("REACT DEVTOOLS ERROR\\nYou need to disable the official version of React Devtools in order to use the beta.");
}
`
`;

var js = (
';(' + globalHook.toString() + '(window))'
Expand Down
10 changes: 10 additions & 0 deletions shells/chrome/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
'use strict';

type Panel = { // eslint-disable-line no-unused-vars
onHidden: {
addListener: (cb: (window: Object) => void) => void,
},
onShown: {
addListener: (cb: (window: Object) => void) => void,
}
Expand All @@ -35,10 +38,17 @@ chrome.devtools.inspectedWindow.eval(`!!(
}

chrome.devtools.panels.create('React', '', 'panel.html', function (panel) {
var reactPanel = null;
panel.onShown.addListener(function (window) {
// when the user switches to the panel, check for an elements tab
// selection
window.panel.getNewSelection();
reactPanel = window.panel;
});
panel.onHidden.addListener(function () {
if (reactPanel) {
reactPanel.hideHighlight();
}
});
});
});
Expand Down