@@ -10,15 +10,12 @@ import { Icon } from "./ui/Icon";
1010import { IconButton } from "./Omnibox" ;
1111import { memoize } from "./memoize" ;
1212
13- let cache = { } ;
14-
1513export const DragTab : Component < {
1614 active : boolean ;
1715 id : number ;
1816 icon : string ;
1917 title : string ;
2018 mousedown : ( e : MouseEvent ) => void ;
21- click : ( ) => void ;
2219 destroy : ( ) => void ;
2320 transitionend : ( ) => void ;
2421} > = function ( cx ) {
@@ -27,7 +24,11 @@ export const DragTab: Component<{
2724 style = "z-index: 0;"
2825 class = "tab"
2926 data-id = { this . id }
30- on :mousedown = { ( e ) => this . mousedown ( e ) }
27+ on :mousedown = { ( e ) => {
28+ this . mousedown ( e ) ;
29+ e . stopPropagation ( ) ;
30+ e . preventDefault ( ) ;
31+ } }
3132 on :transitionend = { ( ) => {
3233 console . log ( "tr end" ) ;
3334 cx . root . style . transition = "" ;
@@ -38,21 +39,14 @@ export const DragTab: Component<{
3839 < div
3940 class = "dragroot"
4041 style = "position: unset;"
41- on :click = { ( ) => this . click ( ) }
4242 on :auxclick = { ( e ) => {
4343 if ( e . button === 1 ) {
4444 this . destroy ( ) ;
4545 }
4646 } }
4747 >
4848 < div class = { use ( this . active ) . map ( ( x ) => `main ${ x ? "active" : "" } ` ) } >
49- { memoize (
50- ( ) => (
51- < img src = { use ( this . icon ) } />
52- ) ,
53- this . icon ,
54- cache
55- ) }
49+ < img src = { use ( this . icon ) } />
5650 < span > { use ( this . title ) } </ span >
5751 < button
5852 class = "close"
@@ -376,27 +370,35 @@ export const Tabs: Component<
376370 this . afterEl . style . transition = "" ;
377371 } ;
378372
373+ let tabcache = { } ;
374+
379375 return (
380376 < div this = { use ( this . container ) . bind ( ) } >
381377 < div class = "extra left" this = { use ( this . leftEl ) . bind ( ) } > </ div >
382- { use ( this . tabs ) . mapEach ( ( tab ) => (
383- < DragTab
384- id = { tab . id }
385- title = { use ( tab . title ) }
386- icon = { use ( tab . icon ) }
387- active = { use ( this . activetab ) . map ( ( x ) => x === tab ) }
388- mousedown = { ( e ) => mouseDown ( e , tab ) }
389- click = { ( ) => {
390- if ( this . activetab !== tab ) {
391- this . activetab = tab ;
392- }
393- } }
394- destroy = { ( ) => {
395- this . destroyTab ( tab ) ;
396- } }
397- transitionend = { transitionend }
398- />
399- ) ) }
378+ { use ( this . tabs ) . mapEach ( ( tab ) =>
379+ memoize (
380+ ( ) => (
381+ < DragTab
382+ id = { tab . id }
383+ title = { use ( tab . title ) }
384+ icon = { use ( tab . icon ) }
385+ active = { use ( this . activetab ) . map ( ( x ) => x === tab ) }
386+ mousedown = { ( e ) => mouseDown ( e , tab ) }
387+ click = { ( ) => {
388+ if ( this . activetab !== tab ) {
389+ this . activetab = tab ;
390+ }
391+ } }
392+ destroy = { ( ) => {
393+ this . destroyTab ( tab ) ;
394+ } }
395+ transitionend = { transitionend }
396+ />
397+ ) ,
398+ tab . id ,
399+ tabcache
400+ )
401+ ) }
400402 < div class = "extra after" this = { use ( this . afterEl ) . bind ( ) } >
401403 < IconButton icon = { iconAdd } click = { this . addTab } > </ IconButton >
402404 </ div >
0 commit comments