@@ -2,8 +2,9 @@ import React from 'react';
22
33import { HelpPopover } from '@gravity-ui/components' ;
44import { ChevronDown } from '@gravity-ui/icons' ;
5- import { Button , Icon } from '@gravity-ui/uikit' ;
5+ import { Button , Icon , Popover } from '@gravity-ui/uikit' ;
66
7+ import { COMMON_POPOVER_PLACEMENT } from '../../constants/common' ;
78import { block } from '../../utils' ;
89
910import './SimpleVerticalAccordeon.scss' ;
@@ -34,6 +35,8 @@ interface SimpleVerticalAccordeonState {
3435 isFirstRender : boolean ;
3536}
3637
38+ const TITLE_TEXT_MAX_WIDTH = 485 ; /** 533px (COMMON_TITLE_MAX_WIDTH) - 48px of padding */
39+
3740export class SimpleVerticalAccordeon extends React . Component <
3841 SimpleVerticalAccordeonProps ,
3942 SimpleVerticalAccordeonState
@@ -45,6 +48,7 @@ export class SimpleVerticalAccordeon extends React.Component<
4548 } ;
4649
4750 componentRef = React . createRef < HTMLDivElement > ( ) ;
51+ titleRef = React . createRef < HTMLElement > ( ) ;
4852
4953 constructor ( props : SimpleVerticalAccordeonProps ) {
5054 super ( props ) ;
@@ -97,19 +101,37 @@ export class SimpleVerticalAccordeon extends React.Component<
97101 return null ;
98102 }
99103
104+ const title = this . getTitle ( ) ;
105+ const titlePopoverDisabled =
106+ ( this . titleRef . current ?. offsetWidth || 0 ) <= TITLE_TEXT_MAX_WIDTH ;
107+
100108 return (
101109 Boolean ( React . Children . count ( children ) ) && (
102110 < div className = { b ( { branch : withBranchView , view : viewLayout } , className ) } >
103111 < div className = { b ( 'header' ) } >
104- < Button
105- view = "flat"
106- className = { b ( 'header-inner' , buttonClassName ) }
107- onClick = { this . handleClick }
108- qa = { `${ name } -accordeon-toggler` }
112+ < Popover
113+ content = { title }
114+ disabled = { titlePopoverDisabled }
115+ placement = { COMMON_POPOVER_PLACEMENT }
109116 >
110- < b className = { b ( 'title' , { size : titleSize } ) } > { this . getTitle ( ) } </ b >
111- < Icon data = { ChevronDown } className = { b ( 'chevron' , { open} ) } size = { 16 } />
112- </ Button >
117+ < Button
118+ view = "flat"
119+ className = { b ( 'header-inner' , buttonClassName ) }
120+ onClick = { this . handleClick }
121+ qa = { `${ name } -accordeon-toggler` }
122+ width = "auto"
123+ >
124+ < b ref = { this . titleRef } className = { b ( 'title' , { size : titleSize } ) } >
125+ { title }
126+ </ b >
127+ < Icon
128+ data = { ChevronDown }
129+ className = { b ( 'chevron' , { open} ) }
130+ size = { 16 }
131+ />
132+ </ Button >
133+ </ Popover >
134+
113135 { this . getTooltip ( ) }
114136 { headerActionsTemplate ? headerActionsTemplate : null }
115137 </ div >
0 commit comments