Skip to content

Commit

Permalink
chore: add autoAlign to TagOverflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmenendez committed Aug 19, 2024
1 parent 330f4af commit 2969013
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ tags associated with the object.
## Component API

<Controls />

### Considerations

Under the hood this component utilizes the Carbon `Popover` component, which has
an experimental auto-align feature. This feature is disabled by default. If you
are interested in trying this feature please refer to the `autoAlign` prop in
the component API table above as well as the
[Carbon Popover documentation](https://react.carbondesignsystem.com/?path=/docs/components-popover--overview#component-api).
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface TagOverflowProps {
allTagsModalSearchPlaceholderText?: string;
allTagsModalTarget?: ReactNode;
allTagsModalTitle?: string;
autoAlign?: boolean;
className?: string;
containingElementRef?: RefObject<HTMLElement>;
items: TagOverflowItem[];
Expand Down Expand Up @@ -94,6 +95,7 @@ export let TagOverflow = forwardRef(
allTagsModalSearchPlaceholderText,
allTagsModalTarget,
allTagsModalTitle,
autoAlign,
className,
containingElementRef,
items,
Expand Down Expand Up @@ -304,6 +306,7 @@ export let TagOverflow = forwardRef(
ref={overflowRef}
popoverOpen={popoverOpen}
setPopoverOpen={setPopoverOpen}
autoAlign={autoAlign}
/>
<TagOverflowModal
allTags={items}
Expand Down Expand Up @@ -365,6 +368,10 @@ TagOverflow.propTypes = {
* title for the show all modal. **Note: Required if more than 10 tags**
*/
allTagsModalTitle: string_required_if_more_than_10_tags,
/**
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
*/
autoAlign: PropTypes.bool,
/**
* Provide an optional class to be applied to the containing node.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TagOverflowItem } from './TagOverflow';

export interface Props {
allTagsModalSearchThreshold?: number;
autoAlign?: boolean;
className?: string;
onShowAllClick: () => void;
overflowAlign?: string;
Expand All @@ -32,6 +33,7 @@ export const TagOverflowPopover = forwardRef(
(props: Props, ref: Ref<HTMLDivElement>) => {
const {
allTagsModalSearchThreshold,
autoAlign,
className,
onShowAllClick,
overflowAlign,
Expand Down Expand Up @@ -89,6 +91,7 @@ export const TagOverflowPopover = forwardRef(
>
<Popover
align={overflowAlign}
autoAlign={autoAlign}
className={cx(className, `${blockClass}__el`)}
dropShadow
highContrast
Expand Down Expand Up @@ -165,6 +168,10 @@ TagOverflowPopover.propTypes = {
* count of overflowTags over which a modal is offered
*/
allTagsModalSearchThreshold: PropTypes.number,
/**
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
*/
autoAlign: PropTypes.bool,
/**
* className
*/
Expand Down

0 comments on commit 2969013

Please sign in to comment.