@@ -6,7 +6,11 @@ import styled from "styled-components";
66import { useFormContext } from "react-hook-form" ;
77import type { ApplicationEventSchedulePriority } from "common/types/common" ;
88import { Priority , type ApplicationNode } from "common/types/gql-types" ;
9- import { filterNonNullable , getLocalizationLang } from "common/src/helpers" ;
9+ import {
10+ filterNonNullable ,
11+ getLocalizationLang ,
12+ truncate ,
13+ } from "common/src/helpers" ;
1014import type {
1115 ApplicationSectionFormValue ,
1216 ApplicationEventScheduleFormType ,
@@ -43,6 +47,9 @@ type DailyOpeningHours =
4347 } [ ]
4448 | null ;
4549
50+ // Mobile layout breaks if the select options are too long
51+ const MAX_SELECT_OPTION_LENGTH = 28 ;
52+
4653const StyledNotification = styled ( Notification ) `
4754 margin-top: var(--spacing-m);
4855` ;
@@ -252,10 +259,15 @@ const Page2 = ({ application, onNext }: Props): JSX.Element => {
252259 const resUnits = filterNonNullable (
253260 resUnitOptions . map ( ( n ) => n ?. reservationUnit )
254261 ) ;
255- const reservationUnitOptions = resUnits . map ( ( n ) => ( {
256- value : n ?. pk ?? 0 ,
257- label : getTranslationSafe ( n , "name" , getLocalizationLang ( i18n . language ) ) ,
258- } ) ) ;
262+ const reservationUnitOptions = resUnits
263+ . map ( ( n ) => ( {
264+ value : n ?. pk ?? 0 ,
265+ label : getTranslationSafe ( n , "name" , getLocalizationLang ( i18n . language ) ) ,
266+ } ) )
267+ . map ( ( { value, label } ) => ( {
268+ value,
269+ label : truncate ( label , MAX_SELECT_OPTION_LENGTH ) ,
270+ } ) ) ;
259271 // TODO why is this done like this?
260272 const openingHours = filterNonNullable (
261273 resUnits . find ( ( n ) => n . pk === reservationUnitPk ) ?. applicationRoundTimeSlots
0 commit comments