Skip to content

Commit 9abcbf2

Browse files
committed
fixup! fix(react-headless-components-preview): address TagPicker positioning review
1 parent 38eb4c4 commit 9abcbf2

10 files changed

Lines changed: 29 additions & 97 deletions

File tree

packages/react-components/react-headless-components-preview/library/etc/tag-picker.api.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ import type { OptionState as OptionState_2 } from '@fluentui/react-combobox';
1818
import { PositioningShorthand } from '@fluentui/react-positioning';
1919
import type * as React_2 from 'react';
2020
import { renderTagPicker_unstable as renderTagPicker } from '@fluentui/react-tag-picker';
21+
import { renderTagPickerButton_unstable as renderTagPickerButton } from '@fluentui/react-tag-picker';
22+
import { renderTagPickerControl_unstable as renderTagPickerControl } from '@fluentui/react-tag-picker';
23+
import { renderTagPickerGroup_unstable as renderTagPickerGroup } from '@fluentui/react-tag-picker';
24+
import { renderTagPickerInput_unstable as renderTagPickerInput } from '@fluentui/react-tag-picker';
2125
import { renderTagPickerList_unstable as renderTagPickerList } from '@fluentui/react-tag-picker';
26+
import { renderTagPickerOption_unstable as renderTagPickerOption } from '@fluentui/react-tag-picker';
2227
import type { Slot } from '@fluentui/react-utilities';
23-
import type { TagGroupBaseState } from '@fluentui/react-tags';
24-
import type { TagGroupContextValues } from '@fluentui/react-tags';
2528
import type { TagPickerBaseProps } from '@fluentui/react-tag-picker';
2629
import type { TagPickerButtonBaseState } from '@fluentui/react-tag-picker';
2730
import { TagPickerButtonBaseProps as TagPickerButtonProps } from '@fluentui/react-tag-picker';
@@ -32,6 +35,7 @@ import type { TagPickerControlBaseState } from '@fluentui/react-tag-picker';
3235
import { TagPickerControlInternalSlots } from '@fluentui/react-tag-picker';
3336
import { TagPickerControlProps } from '@fluentui/react-tag-picker';
3437
import { TagPickerControlSlots } from '@fluentui/react-tag-picker';
38+
import type { TagPickerGroupBaseState } from '@fluentui/react-tag-picker';
3539
import type { TagPickerGroupSlots } from '@fluentui/react-tag-picker';
3640
import type { TagPickerInputBaseState } from '@fluentui/react-tag-picker';
3741
import { TagPickerInputBaseProps as TagPickerInputProps } from '@fluentui/react-tag-picker';
@@ -46,22 +50,17 @@ import { useTagPickerContextValues } from '@fluentui/react-tag-picker';
4650

4751
export { renderTagPicker }
4852

49-
// @public (undocumented)
50-
export const renderTagPickerButton: (state: TagPickerButtonState) => JSXElement;
53+
export { renderTagPickerButton }
5154

52-
// @public
53-
export const renderTagPickerControl: (state: TagPickerControlState) => JSXElement;
55+
export { renderTagPickerControl }
5456

55-
// @public
56-
export const renderTagPickerGroup: (state: TagPickerGroupState, contextValues: TagGroupContextValues) => JSXElement | null;
57+
export { renderTagPickerGroup }
5758

58-
// @public
59-
export const renderTagPickerInput: (state: TagPickerInputState) => JSXElement;
59+
export { renderTagPickerInput }
6060

6161
export { renderTagPickerList }
6262

63-
// @public (undocumented)
64-
export const renderTagPickerOption: (state: TagPickerOptionState) => JSXElement;
63+
export { renderTagPickerOption }
6564

6665
// @public
6766
export const renderTagPickerOptionGroup: (state: OptionGroupState) => JSXElement;
@@ -116,8 +115,7 @@ export type TagPickerGroupProps = ComponentProps<TagPickerGroupSlots>;
116115
export { TagPickerGroupSlots }
117116

118117
// @public
119-
export type TagPickerGroupState = TagGroupBaseState & {
120-
hasSelectedOptions: boolean;
118+
export type TagPickerGroupState = TagPickerGroupBaseState & {
121119
root: {
122120
focusgroup?: string;
123121
'data-disabled'?: string;
@@ -175,25 +173,18 @@ export type TagPickerOptionGroupState = OptionGroupState;
175173

176174
// @public
177175
export type TagPickerOptionProps = OptionProps & {
178-
media?: Slot<'span'>;
176+
media?: Slot<'div'>;
179177
secondaryContent?: Slot<'span'>;
180178
};
181179

182180
// @public (undocumented)
183181
export type TagPickerOptionSlots = OptionSlots & {
184-
media?: Slot<'span'>;
182+
media?: Slot<'div'>;
185183
secondaryContent?: Slot<'span'>;
186184
};
187185

188186
// @public
189-
export type TagPickerOptionState = OptionState & {
190-
components: OptionState['components'] & {
191-
media: 'span';
192-
secondaryContent: 'span';
193-
};
194-
media?: Slot<'span'>;
195-
secondaryContent?: Slot<'span'>;
196-
};
187+
export type TagPickerOptionState = OptionState & ComponentState<TagPickerOptionSlots>;
197188

198189
// @public (undocumented)
199190
export type TagPickerProps = TagPickerBaseProps & {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
import type { JSXElement } from '@fluentui/react-utilities';
2-
import { renderTagPickerButton_unstable } from '@fluentui/react-tag-picker';
3-
4-
import type { TagPickerButtonState } from './TagPickerButton.types';
5-
6-
export const renderTagPickerButton = renderTagPickerButton_unstable as unknown as (
7-
state: TagPickerButtonState,
8-
) => JSXElement;
1+
export { renderTagPickerButton_unstable as renderTagPickerButton } from '@fluentui/react-tag-picker';
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
import type { JSXElement } from '@fluentui/react-utilities';
2-
import { renderTagPickerControl_unstable } from '@fluentui/react-tag-picker';
3-
4-
import type { TagPickerControlState } from './TagPickerControl.types';
5-
6-
/**
7-
* Render the final JSX of the headless TagPickerControl.
8-
*/
9-
export const renderTagPickerControl = renderTagPickerControl_unstable as unknown as (
10-
state: TagPickerControlState,
11-
) => JSXElement;
1+
export { renderTagPickerControl_unstable as renderTagPickerControl } from '@fluentui/react-tag-picker';

packages/react-components/react-headless-components-preview/library/src/components/TagPicker/TagPickerGroup/TagPickerGroup.types.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ComponentProps } from '@fluentui/react-utilities';
2-
import type { TagGroupBaseState } from '@fluentui/react-tags';
3-
import type { TagPickerGroupSlots } from '@fluentui/react-tag-picker';
2+
import type { TagPickerGroupBaseState, TagPickerGroupSlots } from '@fluentui/react-tag-picker';
43

54
export type { TagPickerGroupSlots };
65

@@ -12,11 +11,7 @@ export type TagPickerGroupProps = ComponentProps<TagPickerGroupSlots>;
1211
/**
1312
* State used in rendering the headless TagPickerGroup.
1413
*/
15-
export type TagPickerGroupState = TagGroupBaseState & {
16-
/**
17-
* Whether any options are currently selected. When `false`, the group renders nothing.
18-
*/
19-
hasSelectedOptions: boolean;
14+
export type TagPickerGroupState = TagPickerGroupBaseState & {
2015
root: {
2116
/**
2217
* Native WICG `focusgroup` attribute for arrow-key navigation across the selected tags.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
import type { JSXElement } from '@fluentui/react-utilities';
2-
import { renderTagPickerGroup_unstable } from '@fluentui/react-tag-picker';
3-
import type { TagGroupContextValues } from '@fluentui/react-tags';
4-
5-
import type { TagPickerGroupState } from './TagPickerGroup.types';
6-
7-
/**
8-
* Render the final JSX of the headless TagPickerGroup.
9-
*/
10-
export const renderTagPickerGroup = renderTagPickerGroup_unstable as unknown as (
11-
state: TagPickerGroupState,
12-
contextValues: TagGroupContextValues,
13-
) => JSXElement | null;
1+
export { renderTagPickerGroup_unstable as renderTagPickerGroup } from '@fluentui/react-tag-picker';
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
import type { JSXElement } from '@fluentui/react-utilities';
2-
import { renderTagPickerInput_unstable } from '@fluentui/react-tag-picker';
3-
4-
import type { TagPickerInputState } from './TagPickerInput.types';
5-
6-
/**
7-
* Render the final JSX of the headless TagPickerInput.
8-
*/
9-
export const renderTagPickerInput = renderTagPickerInput_unstable as unknown as (
10-
state: TagPickerInputState,
11-
) => JSXElement;
1+
export { renderTagPickerInput_unstable as renderTagPickerInput } from '@fluentui/react-tag-picker';
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Slot } from '@fluentui/react-utilities';
1+
import type { ComponentState, Slot } from '@fluentui/react-utilities';
22
import type { OptionProps, OptionSlots, OptionState } from '../../Dropdown/Option';
33

44
export type TagPickerOptionSlots = OptionSlots & {
55
/**
66
* Media rendered before the option's text content (e.g. an avatar or icon).
77
*/
8-
media?: Slot<'span'>;
8+
media?: Slot<'div'>;
99
/**
1010
* Secondary text rendered after the option's text content.
1111
*/
@@ -16,18 +16,11 @@ export type TagPickerOptionSlots = OptionSlots & {
1616
* TagPickerOption Props
1717
*/
1818
export type TagPickerOptionProps = OptionProps & {
19-
media?: Slot<'span'>;
19+
media?: Slot<'div'>;
2020
secondaryContent?: Slot<'span'>;
2121
};
2222

2323
/**
2424
* State used in rendering the headless TagPickerOption.
2525
*/
26-
export type TagPickerOptionState = OptionState & {
27-
components: OptionState['components'] & {
28-
media: 'span';
29-
secondaryContent: 'span';
30-
};
31-
media?: Slot<'span'>;
32-
secondaryContent?: Slot<'span'>;
33-
};
26+
export type TagPickerOptionState = OptionState & ComponentState<TagPickerOptionSlots>;
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
import type { JSXElement } from '@fluentui/react-utilities';
2-
import { renderTagPickerOption_unstable } from '@fluentui/react-tag-picker';
3-
4-
import type { TagPickerOptionState } from './TagPickerOption.types';
5-
6-
export const renderTagPickerOption = renderTagPickerOption_unstable as unknown as (
7-
state: TagPickerOptionState,
8-
) => JSXElement;
1+
export { renderTagPickerOption_unstable as renderTagPickerOption } from '@fluentui/react-tag-picker';

packages/react-components/react-headless-components-preview/library/src/components/TagPicker/TagPickerOption/useTagPickerOption.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export const useTagPickerOption = (props: TagPickerOptionProps, ref: React.Ref<H
3232
components: {
3333
// eslint-disable-next-line @typescript-eslint/no-deprecated
3434
...optionState.components,
35-
media: 'span',
35+
media: 'div',
3636
secondaryContent: 'span',
3737
},
38-
media: slot.optional(media, { elementType: 'span' }),
38+
media: slot.optional(media, { elementType: 'div' }),
3939
secondaryContent: slot.optional(secondaryContent, { elementType: 'span' }),
4040
};
4141
};

packages/react-components/react-headless-components-preview/library/src/components/TagPicker/useTagPicker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const useTagPicker = (props: TagPickerProps): TagPickerState => {
1414
const { targetRef, containerRef } = usePositioning(resolvePositioningShorthand(positioning));
1515

1616
const baseState = useTagPickerBase_unstable(baseProps);
17-
const targetRefWithCurrent = useMergedRefs<HTMLDivElement>(targetRef);
1817
const popoverRef = useMergedRefs<HTMLDivElement>(baseState.popoverRef, containerRef);
1918

2019
return {
@@ -24,7 +23,7 @@ export const useTagPicker = (props: TagPickerProps): TagPickerState => {
2423
appearance: 'outline',
2524
inline: true,
2625
size: 'medium',
27-
targetRef: targetRefWithCurrent,
26+
targetRef: targetRef as unknown as TagPickerState['targetRef'],
2827
popoverRef,
2928
};
3029
};

0 commit comments

Comments
 (0)