Skip to content

Commit

Permalink
Tooltip: break word in title and description (#8101)
Browse files Browse the repository at this point in the history
Добавляем перенос строки, если неразрывный текст в Tooltip слишком длинный и не помещается по ширине.
  • Loading branch information
andrey-medvedev-vk authored and actions-user committed Dec 18, 2024
1 parent da90d19 commit a0141db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type TooltipOnShownChange = OnShownChange;
export interface TooltipProps extends AllowedFloatingComponentProps, AllowedTooltipBaseProps {
/**
* Передача `boolean` позволяет контролировать состояния показа и скрытия вручную. Используйте
* совместно с `onShawnChange`.
* совместно с `onShownChange`.
*
* > Если нужно разово инициировать показ тултипа при первом рендере, то используйте `defaultShown`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
background: none;
}

.title,
.description {
word-break: break-word;
}

.arrow {
color: var(--vkui--color_background_contrast_themed);
}
Expand Down
10 changes: 8 additions & 2 deletions packages/vkui/src/components/TooltipBase/TooltipBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ export const TooltipBase = ({
)}
<div className={styles.content} style={maxWidth !== null ? { maxWidth } : undefined}>
<div>
{hasReactNode(title) && <Subhead weight="2">{title}</Subhead>}
{hasReactNode(description) && <Subhead>{description}</Subhead>}
{hasReactNode(title) && (
<Subhead className={styles.title} weight="2">
{title}
</Subhead>
)}
{hasReactNode(description) && (
<Subhead className={styles.description}>{description}</Subhead>
)}
</div>
{typeof onCloseIconClick === 'function' && (
<Tappable
Expand Down

0 comments on commit a0141db

Please sign in to comment.