Skip to content

Commit

Permalink
Merge branch 'main' into 16468-storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
guidari authored Aug 30, 2024
2 parents 354fba5 + bc4acdc commit 0e2e1ee
Show file tree
Hide file tree
Showing 26 changed files with 1,458 additions and 1,641 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion config/jest-config-carbon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"jest-circus": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"jest-watch-typeahead": "^2.0.0",
"sass": "^1.51.0"
"sass": "^1.77.7"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/class-prefix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "4.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
}
}
2 changes: 1 addition & 1 deletion examples/codesandbox-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "vite"
},
"devDependencies": {
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "4.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
}
}
2 changes: 1 addition & 1 deletion examples/id-prefix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "4.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
}
}
2 changes: 1 addition & 1 deletion examples/light-dark-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"devDependencies": {
"eslint": "8.40.0",
"sass": "^1.51.0"
"sass": "^1.77.7"
}
}
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"devDependencies": {
"eslint": "8.40.0",
"eslint-config-next": "13.4.7",
"sass": "^1.51.0"
"sass": "^1.77.7"
}
}
2 changes: 1 addition & 1 deletion examples/v10-token-compat-in-v11/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "4.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
}
}
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@vitejs/plugin-react": "4.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"vite": "^4.3.8"
}
}
2 changes: 1 addition & 1 deletion packages/carbon-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@carbon/test-utils": "^10.31.0",
"fs-extra": "^11.0.0",
"rimraf": "^6.0.0",
"sass": "^1.51.0"
"sass": "^1.77.7"
},
"sideEffects": [
"index.scss",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"remark": "^10.0.1",
"replace-in-file": "^7.0.0",
"rollup": "^2.79.1",
"sass": "^1.51.0",
"sass": "^1.77.7",
"sassdoc": "^2.7.3",
"typescript-config-carbon": "^0.3.0",
"yargs": "^17.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"rimraf": "^6.0.0",
"rollup": "^2.79.1",
"rollup-plugin-strip-banner": "^3.0.0",
"sass": "^1.51.0",
"sass": "^1.77.7",
"sass-loader": "^16.0.0",
"storybook": "^8.2.8",
"storybook-addon-accessibility-checker": "^3.1.61-rc.3",
Expand Down
15 changes: 11 additions & 4 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import deprecate from '../../prop-types/deprecate';
import { usePrefix } from '../../internal/usePrefix';
import { FormContext } from '../FluidForm';
import { useFloating, flip, autoUpdate } from '@floating-ui/react';
import { hide } from '@floating-ui/dom';
import { TranslateWithId } from '../../types/common';

const {
Expand Down Expand Up @@ -381,12 +382,12 @@ const ComboBox = forwardRef(
slug,
...rest
} = props;
const { refs, floatingStyles } = useFloating(
const { refs, floatingStyles, middlewareData } = useFloating(
autoAlign
? {
placement: direction,
strategy: 'fixed',
middleware: [flip()],
middleware: [flip(), hide()],
whileElementsMounted: autoUpdate,
}
: {}
Expand All @@ -395,9 +396,15 @@ const ComboBox = forwardRef(

useEffect(() => {
if (autoAlign) {
Object.keys(floatingStyles).forEach((style) => {
const updatedFloatingStyles = {
...floatingStyles,
visibility: middlewareData.hide?.referenceHidden
? 'hidden'
: 'visible',
};
Object.keys(updatedFloatingStyles).forEach((style) => {
if (refs.floating.current) {
refs.floating.current.style[style] = floatingStyles[style];
refs.floating.current.style[style] = updatedFloatingStyles[style];
}
});
if (parentWidth && refs.floating.current) {
Expand Down
11 changes: 5 additions & 6 deletions packages/react/src/components/ComboButton/ComboButton-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ describe('ComboButton', () => {
);

await userEvent.click(screen.getAllByRole('button')[1]);

expect(screen.getByRole('menu')).toHaveClass(
expect(document.querySelector('ul.cds--menu')).toHaveClass(
`${prefix}--combo-button__${alignment}`
);
});
Expand Down Expand Up @@ -181,10 +180,10 @@ describe('ComboButton', () => {

await userEvent.click(screen.getAllByRole('button')[1]);

expect(screen.getByRole('menu')).toBeInTheDocument();
expect(screen.getByRole('menuitem')).toHaveTextContent(
/^Additional action$/
);
expect(document.querySelector('ul.cds--menu')).toBeInTheDocument();
expect(
document.querySelector('.cds--menu-item__label')
).toHaveTextContent(/^Additional action$/);
});

it('warns when MenuItemSelectable is used in children', async () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/react/src/components/ComboButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
size as floatingSize,
autoUpdate,
} from '@floating-ui/react';
import { hide } from '@floating-ui/dom';
import mergeRefs from '../../tools/mergeRefs';
import { MenuAlignment } from '../MenuButton';
import { TranslateWithId } from '../../types/common';
Expand Down Expand Up @@ -99,7 +100,7 @@ const ComboButton = React.forwardRef<HTMLDivElement, ComboButtonProps>(
const id = useId('combobutton');
const prefix = usePrefix();
const containerRef = useRef<HTMLDivElement>(null);
const middlewares = [flip({ crossAxis: false })];
const middlewares = [flip({ crossAxis: false }), hide()];

if (menuAlignment === 'bottom' || menuAlignment === 'top') {
middlewares.push(
Expand Down Expand Up @@ -134,9 +135,13 @@ const ComboButton = React.forwardRef<HTMLDivElement, ComboButtonProps>(
} = useAttachedMenu(containerRef);

useLayoutEffect(() => {
Object.keys(floatingStyles).forEach((style) => {
const updatedFloatingStyles = {
...floatingStyles,
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible',
};
Object.keys(updatedFloatingStyles).forEach((style) => {
if (refs.floating.current) {
refs.floating.current.style[style] = floatingStyles[style];
refs.floating.current.style[style] = updatedFloatingStyles[style];
}
});
}, [floatingStyles, refs.floating, middlewareData, placement, open]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
size as floatingSize,
autoUpdate,
} from '@floating-ui/react';
import { hide } from '@floating-ui/dom';
import { TranslateWithId } from '../../types/common';

const {
Expand Down Expand Up @@ -388,6 +389,7 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
});
},
}),
hide(),
],
whileElementsMounted: autoUpdate,
}
Expand All @@ -396,9 +398,13 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<

useLayoutEffect(() => {
if (autoAlign) {
Object.keys(floatingStyles).forEach((style) => {
const updatedFloatingStyles = {
...floatingStyles,
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible',
};
Object.keys(updatedFloatingStyles).forEach((style) => {
if (refs.floating.current) {
refs.floating.current.style[style] = floatingStyles[style];
refs.floating.current.style[style] = updatedFloatingStyles[style];
}
});
}
Expand Down
12 changes: 10 additions & 2 deletions packages/react/src/components/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
size as floatingSize,
autoUpdate,
} from '@floating-ui/react';
import { hide } from '@floating-ui/dom';

const {
ItemClick,
Expand Down Expand Up @@ -371,6 +372,7 @@ const MultiSelect = React.forwardRef(
});
},
}),
hide(),
],
whileElementsMounted: autoUpdate,
}
Expand All @@ -379,9 +381,15 @@ const MultiSelect = React.forwardRef(

useLayoutEffect(() => {
if (autoAlign) {
Object.keys(floatingStyles).forEach((style) => {
const updatedFloatingStyles = {
...floatingStyles,
visibility: middlewareData.hide?.referenceHidden
? 'hidden'
: 'visible',
};
Object.keys(updatedFloatingStyles).forEach((style) => {
if (refs.floating.current) {
refs.floating.current.style[style] = floatingStyles[style];
refs.floating.current.style[style] = updatedFloatingStyles[style];
}
});
}
Expand Down
12 changes: 10 additions & 2 deletions packages/react/src/components/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
arrow,
offset,
} from '@floating-ui/react';
import { hide } from '@floating-ui/dom';

interface PopoverContext {
setFloating: React.Ref<HTMLSpanElement>;
Expand Down Expand Up @@ -258,6 +259,7 @@ export const Popover: PopoverComponent = React.forwardRef(
arrow({
element: caretRef,
}),
hide(),
],
whileElementsMounted: autoUpdate,
}
Expand Down Expand Up @@ -286,9 +288,15 @@ export const Popover: PopoverComponent = React.forwardRef(

useEffect(() => {
if (autoAlign) {
Object.keys(floatingStyles).forEach((style) => {
const updatedFloatingStyles = {
...floatingStyles,
visibility: middlewareData.hide?.referenceHidden
? 'hidden'
: 'visible',
};
Object.keys(updatedFloatingStyles).forEach((style) => {
if (refs.floating.current) {
refs.floating.current.style[style] = floatingStyles[style];
refs.floating.current.style[style] = updatedFloatingStyles[style];
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"postcss": "^8.4.14",
"postcss-flexbugs-fixes": "^5.0.2",
"rimraf": "^6.0.0",
"sass": "^1.51.0"
"sass": "^1.77.7"
},
"sideEffects": [
"index.scss",
Expand Down
Loading

0 comments on commit 0e2e1ee

Please sign in to comment.