Skip to content

Commit

Permalink
Added 'wrap' option to TabSelector overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwatrous committed Nov 10, 2023
1 parent 65446e2 commit 332fbb1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/bonito-ui/src/components/form/tab-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ParameterName,
} from "@azure/bonito-core/lib/form";
import { delayedCallback } from "@azure/bonito-core/lib/util";
import { Pivot, PivotItem } from "@fluentui/react/lib/Pivot";
import { IPivotStyles, Pivot, PivotItem } from "@fluentui/react/lib/Pivot";
import * as React from "react";
import { useFormParameter, useUniqueId } from "../../hooks";
import { FormControlProps } from "./form-control";
Expand All @@ -14,7 +14,7 @@ export interface TabSelectorProps<
K extends ParameterName<V>,
D extends ParameterDependencies<V> = ParameterDependencies<V>
> extends FormControlProps<V, K, D> {
overflowBehavior?: "none" | "menu";
overflowBehavior?: "none" | "menu" | "wrap";
options: TabOption<V, K>[];
valueToKey?: (value?: V[K]) => string;
}
Expand Down Expand Up @@ -84,13 +84,21 @@ export function TabSelector<

const toKey = valueToKey ?? defaultValueToKey;

let pivotOverflow: "none" | "menu" = "menu";
let pivotStyles: Partial<IPivotStyles> = {};
if (overflowBehavior === "wrap") {
pivotOverflow = "none";
pivotStyles = { root: { display: "flex", flexWrap: "wrap" } };
}

return (
<Pivot
id={id}
aria-label={ariaLabel ?? param.label}
className={className}
style={style}
overflowBehavior={overflowBehavior ?? "menu"}
styles={pivotStyles}
overflowBehavior={pivotOverflow}
// TODO: Support disabled, errorMessage
// disabled={disabled || param.disabled}
// errorMessage={validationError}
Expand Down

0 comments on commit 332fbb1

Please sign in to comment.