Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ling1726 committed Dec 18, 2023
1 parent 2cdba16 commit 84ee4bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLIn
listbox.ref = listboxRef;
}

listbox = useListboxSlot(props, listbox, triggerRef) as typeof listbox;
listbox = useListboxSlot(baseState, listbox, triggerRef) as typeof listbox;

let triggerSlot: Slot<'input'> = slot.always(props.input, {
defaultProps: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { useTimeout, type ExtractSlotProps, type Slot, mergeCallbacks } from '@fluentui/react-utilities';
import { useTimeout, mergeCallbacks } from '@fluentui/react-utilities';
import type { Slot, ExtractSlotProps } from '@fluentui/react-utilities';
import { useTriggerSlot, UseTriggerSlotState } from '../../utils/useTriggerSlot';
import { OptionValue } from '../../utils/OptionCollection.types';
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useDropdown_unstable = (props: DropdownProps, ref: React.Ref<HTMLBu
if (listbox) {
listbox.ref = listboxRef;
}
listbox = useListboxSlot(props, listbox, triggerRef) as typeof listbox;
listbox = useListboxSlot(baseState, listbox, triggerRef) as typeof listbox;

let trigger: Slot<'button'> = slot.always(props.button, {
defaultProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import * as React from 'react';
import { mergeCallbacks, useId, useEventCallback } from '@fluentui/react-utilities';
import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';
import { Listbox } from '../components/Listbox/Listbox';
import type { ComboboxBaseProps } from './ComboboxBase.types';
import type { ComboboxBaseState } from './ComboboxBase.types';

export type UseTriggerSlotState = Pick<ComboboxBaseState, 'multiselect'>;

/**
* @returns listbox slot with desired behaviour and props
*/
export function useListboxSlot(
props: ComboboxBaseProps,
state: ComboboxBaseState,
listboxSlot: ExtractSlotProps<Slot<typeof Listbox>> | undefined,
triggerRef: React.RefObject<HTMLInputElement> | React.RefObject<HTMLButtonElement>,
): ExtractSlotProps<Slot<typeof Listbox>> {
const { multiselect } = props;
const { multiselect } = state;

/**
* Clicking on the listbox should never blur the trigger
Expand All @@ -31,7 +33,6 @@ export function useListboxSlot(
}, listboxSlot?.onClick),
);

// resolve listbox shorthand props
const listboxId = useId('fluent-listbox', listboxSlot?.id);
const listbox: typeof listboxSlot = {
id: listboxId,
Expand Down

0 comments on commit 84ee4bf

Please sign in to comment.