Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: disabled cursor style, opening when disabled, and hover styles",
"packageName": "@fluentui/react-combobox",
"email": "sarah.higley@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: no interactive hover style when disabled",
"packageName": "@fluentui/react-select",
"email": "sarah.higley@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLIn
setValue,
value,
} = baseState;
const { freeform, multiselect } = props;
const { disabled, freeform, multiselect } = props;

const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({
props,
Expand Down Expand Up @@ -104,6 +104,10 @@ export const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLIn
};

baseState.setOpen = (ev, newState: boolean) => {
if (disabled) {
return;
}

if (!newState && !freeform) {
setValue(undefined);
}
Expand Down Expand Up @@ -136,7 +140,7 @@ export const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLIn
// open Combobox when typing
const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
if (!open && getDropdownActionFromKey(ev) === 'Type') {
setOpen(ev, true);
baseState.setOpen(ev, true);
}
};

Expand Down Expand Up @@ -195,7 +199,6 @@ export const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLIn
},
}),
...baseState,
setOpen,
};

state.root.ref = useMergedRefs(state.root.ref, rootRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ const useStyles = makeStyles({
...shorthands.borderColor('GrayText'),
},
},

disabledText: {
color: tokens.colorNeutralForegroundDisabled,
cursor: 'not-allowed',
},
});

const useIconStyles = makeStyles({
Expand Down Expand Up @@ -227,6 +232,7 @@ export const useDropdownStyles_unstable = (state: DropdownState): DropdownState
dropdownClassNames.root,
styles.root,
styles[appearance],
!disabled && appearance === 'outline' && styles.outlineInteractive,
invalid && appearance !== 'underline' && styles.invalid,
invalid && appearance === 'underline' && styles.invalidUnderline,
disabled && styles.disabled,
Expand All @@ -238,6 +244,7 @@ export const useDropdownStyles_unstable = (state: DropdownState): DropdownState
styles.button,
styles[size],
placeholderVisible && styles.placeholder,
disabled && styles.disabledText,
state.button.className,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';
import { makeStyles, shorthands, useId } from '@fluentui/react-components';
import { Combobox, Option } from '@fluentui/react-combobox';
import type { ComboboxProps } from '@fluentui/react-combobox';

const useStyles = makeStyles({
root: {
// Stack the label above the field with a gap
display: 'grid',
gridTemplateRows: 'repeat(1fr)',
justifyItems: 'start',
...shorthands.gap('2px'),
maxWidth: '400px',
},
});

export const Disabled = (props: Partial<ComboboxProps>) => {
const comboId = useId('combo-disabled');
const options = ['Cat', 'Dog', 'Ferret', 'Fish', 'Hamster', 'Snake'];
const styles = useStyles();
return (
<div className={styles.root}>
<label id={comboId}>Best pet</label>
<Combobox aria-labelledby={comboId} disabled placeholder="Select an animal" {...props}>
{options.map(option => (
<Option key={option}>{option}</Option>
))}
</Combobox>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { MultiselectWithValueString } from './ComboboxMultiselectWithValueString
export { Grouped } from './ComboboxGrouped.stories';
export { Appearance } from './ComboboxAppearance.stories';
export { Size } from './ComboboxSize.stories';
export { Disabled } from './ComboboxDisabled.stories';

export default {
title: 'Preview Components/Combobox',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';
import { makeStyles, shorthands, useId } from '@fluentui/react-components';
import { Dropdown, Option } from '@fluentui/react-combobox';
import type { DropdownProps } from '@fluentui/react-combobox';

const useStyles = makeStyles({
root: {
// Stack the label above the field with a gap
display: 'grid',
gridTemplateRows: 'repeat(1fr)',
justifyItems: 'start',
...shorthands.gap('2px'),
maxWidth: '400px',
},
});

export const Disabled = (props: Partial<DropdownProps>) => {
const comboId = useId('combo-disabled');
const options = ['Cat', 'Dog', 'Ferret', 'Fish', 'Hamster', 'Snake'];
const styles = useStyles();
return (
<div className={styles.root}>
<label id={comboId}>Best pet</label>
<Dropdown aria-labelledby={comboId} disabled placeholder="Select an animal" {...props}>
{options.map(option => (
<Option key={option}>{option}</Option>
))}
</Dropdown>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export { ComplexOptions } from './DropdownComplexOptions.stories';
export { CustomOptions } from './DropdownCustomOptions.stories';
export { Multiselect } from './DropdownMultiselect.stories';
export { Size } from './DropdownSize.stories';
export { Disabled } from './DropdownDisabled.stories';

export default {
title: 'Preview Components/Dropdown',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ const useSelectStyles = makeStyles({
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.border('1px', 'solid', tokens.colorNeutralStroke1),
borderBottomColor: tokens.colorNeutralStrokeAccessible,

},
outlineInteractive: {
'&:hover': {
...shorthands.borderColor(tokens.colorNeutralStroke1Hover),
borderBottomColor: tokens.colorNeutralStrokeAccessible,
Expand Down Expand Up @@ -256,6 +257,7 @@ export const useSelectStyles_unstable = (state: SelectState): SelectState => {
selectStyles.base,
selectStyles[size],
selectStyles[appearance],
!disabled && appearance === 'outline' && selectStyles.outlineInteractive,
!disabled && invalid && appearance !== 'underline' && selectStyles.invalid,
!disabled && invalid && appearance === 'underline' && selectStyles.invalidUnderline,
disabled && selectStyles.disabled,
Expand Down