Skip to content

Commit

Permalink
Merge branch 'main' into fix-exported-types
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGenius authored Oct 2, 2023
2 parents a63a6fe + be6534e commit f7b2bbe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .storybook/focus-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {addons, } from '@storybook/addons';

addons.register('initialFocus', () => {
addons.getChannel().on('currentStoryWasSet', () => focusIframe());
})

const focusIframe = () => {
const previewIframe: HTMLInputElement | null = document.querySelector('#storybook-preview-iframe');

previewIframe?.focus?.();
}
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const config: StorybookConfig = {
'@storybook/addon-interactions',
'@storybook/preset-scss',
'storybook-preset-inline-svg',
'./theme-addon/register.tsx'
'./theme-addon/register.tsx',
'./focus-addon/register.tsx'
],
framework: {
name: '@storybook/react-webpack5',
Expand Down
8 changes: 4 additions & 4 deletions src/components/CompositeBar/CompositeBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({

const onMouseEnterByIndex = useCallback(
(itemIndex) => () => {
if (multipleTooltip) {
if (multipleTooltip && document.hasFocus()) {
let multipleTooltipActiveValue = multipleTooltipActive;
if (!multipleTooltipActive && itemIndex !== lastClickedItemIndex) {
multipleTooltipActiveValue = true;
Expand All @@ -139,7 +139,7 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
);

const onMouseLeave = useCallback(() => {
if (compact) {
if (compact && document.hasFocus()) {
ref.current?.activateItem(undefined as unknown as number);
if (
multipleTooltip &&
Expand Down Expand Up @@ -220,9 +220,9 @@ const CompositeBarView: FC<CompositeBarViewProps> = ({
}}
/>
</div>
{type === 'menu' && (
{type === 'menu' && multipleTooltip && (
<MultipleTooltip
open={compact && multipleTooltip && multipleTooltipActive}
open={compact && multipleTooltipActive}
anchorRef={tooltipRef}
placement={['right-start']}
items={items}
Expand Down

0 comments on commit f7b2bbe

Please sign in to comment.