Skip to content

Commit b3b2fbe

Browse files
committed
Allow horizontal scrolling in multi-select cell
1 parent e7d8fce commit b3b2fbe

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/cells/src/cells/multi-select-cell.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,21 @@ const Editor: ReturnType<ProvideEditorCallback<MultiSelectCell>> = p => {
159159
// Apply styles to the react-select component.
160160
// All components: https://react-select.com/components
161161
const colorStyles: StylesConfig<SelectOption, true> = {
162-
control: base => ({
162+
control: (base, state) => ({
163163
...base,
164164
border: 0,
165165
boxShadow: "none",
166166
backgroundColor: theme.bgCell,
167+
// Allow interaction (e.g. wheel scrolling) even when the select is disabled
168+
pointerEvents: state.isDisabled ? "auto" : base.pointerEvents,
169+
cursor: state.isDisabled ? "default" : base.cursor,
170+
}),
171+
valueContainer: base => ({
172+
...base,
173+
// Keep default wrapping so multiple chips can move to new lines
174+
flexWrap: base.flexWrap ?? "wrap",
175+
overflowX: "auto",
176+
overflowY: "hidden",
167177
}),
168178
menu: styles => ({
169179
...styles,
@@ -227,6 +237,8 @@ const Editor: ReturnType<ProvideEditorCallback<MultiSelectCell>> = p => {
227237
...styles,
228238
backgroundColor: data.color ?? theme.bgBubble,
229239
borderRadius: `${theme.roundingRadius ?? theme.bubbleHeight / 2}px`,
240+
flexShrink: 0,
241+
whiteSpace: "nowrap",
230242
};
231243
},
232244
multiValueLabel: (styles, { data, isDisabled }) => {
@@ -249,6 +261,7 @@ const Editor: ReturnType<ProvideEditorCallback<MultiSelectCell>> = p => {
249261
alignItems: "center",
250262
display: "flex",
251263
height: theme.bubbleHeight,
264+
whiteSpace: "nowrap",
252265
};
253266
},
254267
multiValueRemove: (styles, { data, isDisabled, isFocused }) => {
@@ -343,7 +356,7 @@ const Editor: ReturnType<ProvideEditorCallback<MultiSelectCell>> = p => {
343356
value={resolveValues(value, options, allowDuplicates)}
344357
onKeyDown={cell.readonly ? undefined : handleKeyDown}
345358
menuPlacement={"auto"}
346-
menuPortalTarget={portalElementRef?.current ?? document.getElementById("portal")}
359+
menuPortalTarget={portalElementRef?.current ?? document.getElementById("portal")}
347360
autoFocus={true}
348361
openMenuOnFocus={true}
349362
openMenuOnClick={true}

0 commit comments

Comments
 (0)