Skip to content

Commit d8e8599

Browse files
authored
Combobox design fixes (#1492)
* changing combobox button width to be 32px * updating combobox action button style when menu is open * tentative stab at adjusting label and combobox input distance * updating css to match textfield 5.3 XD * adding line height to quiet textfield input to match XD fixes the icon position for quiet textarea w/ validation and normal icon * fixing combobox field button hover styles so they dont apply for isQuiet * updating textfield and inputgroup quiet focus styles when field is focused (not keyboard focused just clicked), should not have a box-shadow * fixing quiet combobox menu so input text aligns with menu text * making fieldbutton gray 900 hover style only appear if the button itself is hovered * altering textfield label text line height to match XD design this value matched my photoshop overlap comparison between XD and storybook best * adding negative margin so label can use line height specified in XD * removing label positioning changes * fixing invalid quiet combobox boxshadow so it only appears on keyboard focus * passing isPressed to combobox button when popover is open * removing some extraneous props
1 parent c668529 commit d8e8599

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

packages/@adobe/spectrum-css-temp/components/inputgroup/index.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ governing permissions and limitations under the License.
2525
--spectrum-datepicker-range-dash-padding-top: 0;
2626
--spectrum-datepicker-range-dash-line-height: calc(var(--spectrum-textfield-height) - var(--spectrum-global-dimension-size-100));
2727

28-
--spectrum-combobox-button-width: calc(var(--spectrum-global-dimension-size-400) + var(--spectrum-global-dimension-size-25));
28+
--spectrum-combobox-button-width: var(--spectrum-global-dimension-size-400);
2929
}
3030

3131
.spectrum-InputGroup {
@@ -121,6 +121,12 @@ governing permissions and limitations under the License.
121121
}
122122
}
123123

124+
.spectrum-InputGroup-popover--quiet {
125+
/* Define this var so it can be read from JS */
126+
--spectrum-dropdown-quiet-offset: calc(var(--spectrum-dropdown-quiet-popover-offset-x) + var(--spectrum-popover-border-size));
127+
margin-inline-end: calc(var(--spectrum-dropdown-quiet-offset) * -1);
128+
}
129+
124130
.spectrum-Datepicker--range {
125131
border-radius: var(--spectrum-border-radius);
126132
/* Input Group */

packages/@adobe/spectrum-css-temp/components/inputgroup/skin.css

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,20 @@ governing permissions and limitations under the License.
101101
}
102102
}
103103

104-
/* Always add the 2px ring for keyboard focus for quiet inputgroups */
105104
&.is-focused {
105+
.spectrum-FieldButton {
106+
border-color: var(--spectrum-textfield-quiet-border-color-key-focus);
107+
}
108+
109+
&.spectrum-InputGroup--invalid,
110+
&:invalid {
111+
.spectrum-FieldButton {
112+
border-color: var(--spectrum-textfield-border-color-error);
113+
}
114+
}
115+
}
116+
117+
&:focus-ring {
106118
.spectrum-InputGroup-input {
107119
box-shadow: 0 1px 0 var(--spectrum-textfield-quiet-border-color-key-focus);
108120
}
@@ -120,7 +132,6 @@ governing permissions and limitations under the License.
120132

121133
.spectrum-FieldButton {
122134
box-shadow: 0 1px 0 var(--spectrum-textfield-border-color-error);
123-
border-color: var(--spectrum-textfield-border-color-error);
124135
}
125136
}
126137
}

packages/@adobe/spectrum-css-temp/components/textfield/skin.css

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ governing permissions and limitations under the License.
115115
&:focus,
116116
&.is-focused {
117117
border-color: var(--spectrum-textfield-quiet-border-color-key-focus);
118-
box-shadow: 0 1px 0 var(--spectrum-textfield-quiet-border-color-key-focus);
119118
}
120119

121120
&:focus-ring {
@@ -134,11 +133,6 @@ governing permissions and limitations under the License.
134133
&:invalid {
135134
border-color: var(--spectrum-textfield-border-color-error);
136135

137-
&:focus,
138-
&.is-focused {
139-
box-shadow: 0 1px 0 var(--spectrum-textfield-border-color-error);
140-
}
141-
142136
&:focus-ring { /* might break things due to pre-defined focus-ring */
143137
&:not(:active) {
144138
border-color: var(--spectrum-textfield-border-color-error);
@@ -160,11 +154,6 @@ governing permissions and limitations under the License.
160154
}
161155

162156
.spectrum-Textfield--quiet.spectrum-Textfield--invalid & {
163-
&:focus,
164-
&.is-focused {
165-
box-shadow: 0 1px 0 var(--spectrum-textfield-border-color-error);
166-
}
167-
168157
&:focus-ring { /* might break things due to pre-defined focus-ring */
169158
&:not(:active) {
170159
box-shadow: 0 1px 0 var(--spectrum-textfield-border-color-error);

packages/@react-spectrum/combobox/src/ComboBox.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
6868
menuTrigger = 'input',
6969
shouldFlip = true,
7070
direction = 'bottom',
71+
isQuiet,
7172
loadingState,
7273
onLoadMore
7374
} = props;
@@ -134,14 +135,16 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
134135

135136
let style = {
136137
...overlayProps.style,
137-
width: menuWidth
138+
width: isQuiet ? null : menuWidth,
139+
minWidth: isQuiet ? `calc(${menuWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : menuWidth
138140
};
139141

140142
return (
141143
<>
142144
<Field {...props} labelProps={labelProps} ref={domRef}>
143145
<ComboBoxInput
144146
{...props}
147+
isOpen={state.isOpen}
145148
loadingState={loadingState}
146149
inputProps={inputProps}
147150
inputRef={inputRef}
@@ -151,6 +154,7 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
151154
<Popover
152155
isOpen={state.isOpen}
153156
UNSAFE_style={style}
157+
UNSAFE_className={classNames(styles, 'spectrum-InputGroup-popover', {'spectrum-InputGroup-popover--quiet': isQuiet})}
154158
ref={popoverRef}
155159
placement={placement}
156160
hideArrow
@@ -164,8 +168,6 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
164168
focusOnPointerEnter
165169
layout={layout}
166170
state={state}
167-
// Set max height: inherit so Tray scrolling works
168-
UNSAFE_style={{maxHeight: 'inherit'}}
169171
shouldUseVirtualFocus
170172
isLoading={loadingState === 'loadingMore'}
171173
onLoadMore={onLoadMore}
@@ -185,7 +187,6 @@ interface ComboBoxInputProps extends SpectrumComboBoxProps<unknown> {
185187
inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement>,
186188
triggerProps: AriaButtonProps,
187189
triggerRef: RefObject<FocusableRefValue<HTMLElement>>,
188-
className?: string,
189190
style?: React.CSSProperties
190191
}
191192

@@ -201,8 +202,9 @@ const ComboBoxInput = React.forwardRef(function ComboBoxInput(props: ComboBoxInp
201202
triggerRef,
202203
autoFocus,
203204
style,
204-
className,
205-
loadingState
205+
UNSAFE_className,
206+
loadingState,
207+
isOpen
206208
} = props;
207209
let {hoverProps, isHovered} = useHover({});
208210
let formatMessage = useMessageFormatter(intlMessages);
@@ -243,7 +245,7 @@ const ComboBoxInput = React.forwardRef(function ComboBoxInput(props: ComboBoxInp
243245
'spectrum-InputGroup--invalid': validationState === 'invalid',
244246
'is-hovered': isHovered
245247
},
246-
className
248+
UNSAFE_className
247249
)
248250
}>
249251
<TextFieldBase
@@ -272,7 +274,7 @@ const ComboBoxInput = React.forwardRef(function ComboBoxInput(props: ComboBoxInp
272274
validationState={validationState}
273275
isLoading={loadingState === 'loading' || loadingState === 'filtering'}
274276
loadingIndicator={loadingState != null && loadingCircle} />
275-
<PressResponder preventFocusOnPress>
277+
<PressResponder preventFocusOnPress isPressed={isOpen}>
276278
<FieldButton
277279
{...triggerProps}
278280
ref={triggerRef}

0 commit comments

Comments
 (0)