diff --git a/src/core/LanguageMenu/LanguageMenu.baseStyles.tsx b/src/core/LanguageMenu/LanguageMenu.baseStyles.tsx index 8b35510e5..de32d3f78 100644 --- a/src/core/LanguageMenu/LanguageMenu.baseStyles.tsx +++ b/src/core/LanguageMenu/LanguageMenu.baseStyles.tsx @@ -13,11 +13,12 @@ export const baseStyles = withSuomifiTheme( &.fi-language-menu-language_button { ${element({ theme })} ${theme.typography.actionElementInnerTextBold} - padding: 9px ${theme.spacing.xs}; + padding: 9px ${theme.spacing.xs}; line-height: 24px; background-color: ${theme.colors.whiteBase}; border: 1px solid transparent; border-radius: ${theme.radius.basic}; + word-break: break-word; & > .fi-language-menu-language_icon { height: 1em; width: 1em; @@ -92,12 +93,14 @@ export const languageMenuPopoverStyles = withSuomifiTheme( & [data-reach-menu-items] { border: 0; padding: 0; + white-space: normal; } & [data-reach-menu-item].fi-language-menu_item { ${element({ theme })} ${theme.typography.bodyText} - &[data-selected] { + word-break: break-word; + &[data-selected] { ${theme.typography.bodyText} color: ${theme.colors.blackBase}; background-color: ${theme.colors.highlightLight3}; diff --git a/src/core/LanguageMenu/LanguageMenu.tsx b/src/core/LanguageMenu/LanguageMenu.tsx index 1c2f39eaa..fea005faf 100644 --- a/src/core/LanguageMenu/LanguageMenu.tsx +++ b/src/core/LanguageMenu/LanguageMenu.tsx @@ -84,6 +84,11 @@ const LanguageMenuPopoverPosition = ( left: `${targetRect.left - popoverRect.width + targetRect.width}px`, // eslint-disable-next-line no-undef top: `${targetRect.top + targetRect.height + window.pageYOffset}px`, + maxWidth: `${Math.max( + targetRect.width, + targetRect.width + targetRect.left - 30, + )}px`, + minWidth: `${targetRect.width - 2}px`, }; }; diff --git a/src/core/LanguageMenu/__snapshots__/LanguageMenu.test.tsx.snap b/src/core/LanguageMenu/__snapshots__/LanguageMenu.test.tsx.snap index 612f165ce..a89b23aed 100644 --- a/src/core/LanguageMenu/__snapshots__/LanguageMenu.test.tsx.snap +++ b/src/core/LanguageMenu/__snapshots__/LanguageMenu.test.tsx.snap @@ -50,6 +50,7 @@ exports[`calling render with the same component on the same container does not r background-color: hsl(0,0%,100%); border: 1px solid transparent; border-radius: 2px; + word-break: break-word; } .c1 > [data-reach-menu-button].fi-language-menu_button.fi-language-menu-language_button > .fi-language-menu-language_icon {