Skip to content

Commit 7af467a

Browse files
dirkwadirkwa
andauthored
fix(admin-ui/priorities): wrap long source labels in override picker (#2790)
Long device names (e.g. a Raymarine/Furuno label that includes the full sourceRef) were clipped to a single line in the path-override Source picker, forcing the column too wide and hiding the rest of the name. Let the selected value and the menu options wrap across lines and grow the control vertically so the full label stays readable. Co-authored-by: dirkwa <dirkwahrtheit@gmail.com>
1 parent 808c21d commit 7af467a

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

packages/server-admin-ui/src/views/ServerConfig/PrefsEditor.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
66
import { faArrowUp } from '@fortawesome/free-solid-svg-icons/faArrowUp'
77
import { faArrowDown } from '@fortawesome/free-solid-svg-icons/faArrowDown'
88
import { faTrash } from '@fortawesome/free-solid-svg-icons/faTrash'
9-
import Select from 'react-select'
9+
import Select, { type StylesConfig } from 'react-select'
1010
import { useStore, useSourceStatus, useSourceStatusLoaded } from '../../store'
1111
import { type SourcesData } from '../../utils/sourceLabels'
1212
import { DEFAULT_FALLBACK_MS } from '../../utils/sourceGroups'
@@ -51,6 +51,37 @@ function isFanOut(priorities: Priority[]): boolean {
5151
return priorities.length === 1 && priorities[0].sourceRef === FANOUT_SOURCEREF
5252
}
5353

54+
// react-select's default single-line control height.
55+
const SELECT_MIN_HEIGHT = 38
56+
// Above Bootstrap's modal/dropdown layers so the portalled menu stays on top.
57+
const MENU_PORTAL_Z_INDEX = 9999
58+
59+
// Long device labels (e.g. "Raymarine E70310 (ttyUSB0.c078915de76…)")
60+
// otherwise get clipped to a single line. Let the selected value and the
61+
// menu options wrap so the full name + sourceRef stays readable in the
62+
// narrow priorities column, and grow the control vertically to fit.
63+
const wrappingSelectStyles: StylesConfig<SelectOption, false> = {
64+
control: (base) => ({
65+
...base,
66+
minHeight: SELECT_MIN_HEIGHT,
67+
height: 'auto'
68+
}),
69+
valueContainer: (base) => ({ ...base, flexWrap: 'wrap' }),
70+
singleValue: (base) => ({
71+
...base,
72+
whiteSpace: 'normal',
73+
overflow: 'visible',
74+
textOverflow: 'clip',
75+
wordBreak: 'break-word'
76+
}),
77+
option: (base) => ({
78+
...base,
79+
whiteSpace: 'normal',
80+
wordBreak: 'break-word'
81+
}),
82+
menuPortal: (base) => ({ ...base, zIndex: MENU_PORTAL_Z_INDEX })
83+
}
84+
5485
export const PrefsEditor: React.FC<PrefsEditorProps> = ({
5586
path,
5687
priorities,
@@ -222,6 +253,7 @@ export const PrefsEditor: React.FC<PrefsEditorProps> = ({
222253
<div style={{ flex: 1 }}>
223254
<Select
224255
menuPortalTarget={document.body}
256+
styles={wrappingSelectStyles}
225257
options={availableOptions}
226258
value={
227259
sourceRef

0 commit comments

Comments
 (0)