11// @flow
22
3- import React , { useState , useLayoutEffect , useEffect } from "react"
4- import { makeStyles } from "@material-ui/styles"
3+ import React , { useState , useEffect , useMemo } from "react"
54import type { Label as LabelType } from "../../types.js"
65import LabelButton from "../LabelButton"
7- import Tooltip from "@material-ui/core/Tooltip"
8-
9- const useStyles = makeStyles ( {
10- tooltip : {
11- whiteSpace : "pre-wrap"
12- }
13- } )
6+ import colors from "../../colors"
147
158const findRouteFromParents = ( labelId , labels ) => {
169 if ( ! labelId ) return [ ]
@@ -46,7 +39,7 @@ export default ({
4639 }
4740 }
4841
49- useLayoutEffect ( ( ) => {
42+ useEffect ( ( ) => {
5043 const eventFunc = e => {
5144 if ( hotkeyLabelMap [ e . key ] ) {
5245 const labelId = hotkeyLabelMap [ e . key ]
@@ -66,9 +59,7 @@ export default ({
6659 return ( ) => {
6760 window . removeEventListener ( "keydown" , eventFunc )
6861 }
69- } )
70-
71- const c = useStyles ( )
62+ } , [ changeParents , onSelectLabel ] )
7263
7364 return (
7465 < div >
@@ -91,22 +82,14 @@ export default ({
9182 hasChildren : labels . some ( l2 => l2 . parent === l . id )
9283 } ) )
9384 . map ( ( l , i ) => (
94- < Tooltip
95- // open={helpOpen}
96- classes = { { tooltip : c . tooltip } }
97- key = { i }
98- title = { l . description || "No Description" }
99- placement = "bottom"
100- >
101- < LabelButton
102- small
103- { ...l }
104- hotkey = { labelHotkeyMap [ l . id ] }
105- onClick = { ( ) => {
106- changeParents ( parents . slice ( 0 , parents . indexOf ( l . id ) + 1 ) )
107- } }
108- />
109- </ Tooltip >
85+ < LabelButton
86+ small
87+ { ...l }
88+ hotkey = { labelHotkeyMap [ l . id ] }
89+ onClick = { ( ) => {
90+ changeParents ( parents . slice ( 0 , parents . indexOf ( l . id ) + 1 ) )
91+ } }
92+ />
11093 ) ) }
11194 </ div >
11295 ) }
@@ -118,26 +101,18 @@ export default ({
118101 hasChildren : labels . some ( l2 => l2 . parent === l . id )
119102 } ) )
120103 . map ( ( l , i ) => (
121- < Tooltip
122- key = { i }
123- classes = { { tooltip : c . tooltip } }
124- title = { l . description || "No Description" }
125- placement = "bottom"
126- >
127- < div >
128- < LabelButton
129- { ...l }
130- hotkey = { labelHotkeyMap [ l . id ] }
131- onClick = {
132- ! l . hasChildren
133- ? onSelectLabel
134- : ( ) => {
135- changeParents ( parents . concat ( [ l . id ] ) )
136- }
137- }
138- />
139- </ div >
140- </ Tooltip >
104+ < LabelButton
105+ key = { l . id }
106+ { ...l }
107+ hotkey = { labelHotkeyMap [ l . id ] }
108+ onClick = {
109+ ! l . hasChildren
110+ ? onSelectLabel
111+ : ( ) => {
112+ changeParents ( parents . concat ( [ l . id ] ) )
113+ }
114+ }
115+ />
141116 ) ) }
142117 </ div >
143118 </ div >
0 commit comments