@@ -26,7 +26,8 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
2626 | undefined
2727 const source = feature . get ( 'source' )
2828 const summary = feature . get ( 'summary' )
29- const obj = Object . fromEntries ( model . sources . map ( ent => [ ent . name , ent ] ) )
29+ const obj = Object . fromEntries ( model . sources . map ( ent => [ ent . source , ent ] ) )
30+ const obj2 = obj [ source ]
3031
3132 return (
3233 < div ref = { ref } >
@@ -42,26 +43,31 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
4243 </ tr >
4344 </ thead >
4445 < tbody >
45- { Object . entries ( sources ) . map ( ( [ source , data ] ) => (
46- < tr key = { source } >
47- < td >
48- < div
49- style = { {
50- width : 16 ,
51- height : 16 ,
52- background : obj [ source ] ! . color ,
53- } }
54- > </ div >
55- </ td >
56- < td > { source } </ td >
57- < td > { toP ( data . score ) } </ td >
58- </ tr >
59- ) ) }
46+ { Object . entries ( sources ) . map ( ( [ source , data ] ) => {
47+ const sourceInfo = obj [ source ]
48+ return (
49+ < tr key = { source } >
50+ < td >
51+ { sourceInfo && (
52+ < div
53+ style = { {
54+ width : 16 ,
55+ height : 16 ,
56+ background : sourceInfo . color ,
57+ } }
58+ > </ div >
59+ ) }
60+ </ td >
61+ < td > { sourceInfo ?. name || source } </ td >
62+ < td > { toP ( data . score ) } </ td >
63+ </ tr >
64+ )
65+ } ) }
6066 </ tbody >
6167 </ table >
6268 ) : (
6369 < span >
64- { source } { ' ' }
70+ { obj2 ?. name || source } { ' ' }
6571 { summary
6672 ? `min:${ toP ( feature . get ( 'minScore' ) ) } avg:${ toP (
6773 feature . get ( 'score' ) ,
@@ -76,18 +82,17 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
7682
7783type Coord = [ number , number ]
7884
79- const WiggleTooltip = observer (
80- ( props : {
81- model : { featureUnderMouse : Feature ; sources : Source [ ] ; rowHeight : number }
82- height : number
83- offsetMouseCoord : Coord
84- clientMouseCoord : Coord
85- clientRect ?: DOMRect
86- TooltipContents ?: TooltipContentsComponent
87- } ) => {
88- return < Tooltip useClientY TooltipContents = { TooltipContents } { ...props } />
89- } ,
90- )
85+ const WiggleTooltip = observer ( function ( props : {
86+ model : { featureUnderMouse : Feature ; sources : Source [ ] ; rowHeight : number }
87+ height : number
88+ offsetMouseCoord : Coord
89+ clientMouseCoord : Coord
90+ clientRect ?: DOMRect
91+ TooltipContents ?: TooltipContentsComponent
92+ } ) {
93+ return < Tooltip useClientY TooltipContents = { TooltipContents } { ...props } />
94+ } )
95+
9196export default WiggleTooltip
9297
9398export { default as Tooltip } from '../../Tooltip'
0 commit comments