Skip to content

Commit

Permalink
Dim owners that have been filtered from the tree in rendered-by list
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed May 9, 2019
1 parent 0722a5a commit 17516b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/devtools/store.js
Expand Up @@ -377,6 +377,10 @@ export default class Store extends EventEmitter {
this.emit('isProfiling');
}

containsElement(id: number): boolean {
return this._idToElement.get(id) != null;
}

getElementAtIndex(index: number): Element | null {
if (index < 0 || index >= this.numElements) {
console.warn(
Expand Down
5 changes: 5 additions & 0 deletions src/devtools/views/Components/SelectedElement.css
Expand Up @@ -87,3 +87,8 @@
.CannotSuspendWarningMessage {
font-size: var(--font-size-sans-large);
}

.NotInStore {
color: var(--color-dim);
cursor: default;
}
8 changes: 6 additions & 2 deletions src/devtools/views/Components/SelectedElement.js
Expand Up @@ -306,6 +306,7 @@ function InspectedElementView({
key={owner.id}
displayName={owner.displayName}
id={owner.id}
isInStore={store.containsElement(owner.id)}
/>
))}
</div>
Expand All @@ -314,7 +315,9 @@ function InspectedElementView({
);
}

function OwnerView({ displayName, id }: { displayName: string, id: number }) {
type OwnerViewProps = {| displayName: string, id: number, isInStore: boolean |};

function OwnerView({ displayName, id, isInStore }: OwnerViewProps) {
const dispatch = useContext(TreeDispatcherContext);

const handleClick = useCallback(
Expand All @@ -329,7 +332,8 @@ function OwnerView({ displayName, id }: { displayName: string, id: number }) {
return (
<button
key={id}
className={styles.Owner}
className={`${styles.Owner} ${isInStore ? '' : styles.NotInStore}`}
disabled={!isInStore}
onClick={handleClick}
title={displayName}
>
Expand Down

0 comments on commit 17516b7

Please sign in to comment.