Skip to content
Snippets Groups Projects
Commit c1c82d65 authored by Miguel Rincon's avatar Miguel Rincon
Browse files

feat(BaseDropdown): Adds "right-start" placement

This change allows a new placement option for dropdowns
so they can support "dropright" placements.

This option allows building UIs such as the pipeline
job groups.
parent 51516603
No related branches found
No related tags found
1 merge request!4061feat(BaseDropdown): Adds "right-start" placement
......@@ -162,6 +162,27 @@ describe('base dropdown', () => {
);
});
it('initializes Floating UI with reference and floating elements and config for `right-start` aligned menu', async () => {
buildWrapper({ placement: 'right-start' });
await findDefaultDropdownToggle().trigger('click');
expect(computePosition).toHaveBeenCalledWith(
findDefaultDropdownToggle().element,
findDropdownMenu().element,
{
placement: 'right-start',
strategy: 'absolute',
middleware: [
offset({ mainAxis: DEFAULT_OFFSET }),
autoPlacement({
alignment: 'start',
allowedPlacements: ['right-start', 'right-end', 'left-start', 'left-end'],
}),
],
}
);
});
it("passes custom offset to Floating UI's middleware", async () => {
const customOffset = { mainAxis: 10, crossAxis: 40 };
buildWrapper({
......
......@@ -146,6 +146,7 @@ export const dropdownVariantOptions = {
};
export const dropdownPlacements = {
'right-start': 'right-start',
left: 'bottom-start',
center: 'bottom',
right: 'bottom-end',
......@@ -159,6 +160,7 @@ const dropdownAnyCornerPlacement = [
];
export const dropdownAllowedAutoPlacements = {
'right-start': ['right-start', 'right-end', 'left-start', 'left-end'],
left: dropdownAnyCornerPlacement,
center: [dropdownPlacements.center, 'top'],
right: dropdownAnyCornerPlacement,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment