Skip to content

Commit

Permalink
Merge branch 'main' into Breadcrumbs-renderItem
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanVor authored Mar 14, 2024
2 parents 3b0e40b + 1e8ff11 commit a5fe96b
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 21 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ name: Release

on:
push:
branches: [main]
branches:
- main
- release/v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: gravity-ui/release-action@v1
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
- name: Release from ${{ github.ref_name }}
uses: gravity-ui/release-action@v1
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
default-branch: ${{ github.ref_name != 'main' && github.ref_name || null }}
npm-dist-tag: ${{ github.ref_name != 'main' && 'untagged' || 'latest' }}
1 change: 0 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
/src/components/controls/TextInput @korvin89
/src/components/Toaster @ogonkov
/src/components/Tooltip @amje
/src/components/theme @resure

/src/hooks/useActionHandlers @ogonkov
/src/hooks/useFileInput @korvin89
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const BUILD_DIR = path.resolve('build');

task('clean', (done) => {
rimrafSync(BUILD_DIR);
rimrafSync('styles/**/*.css');
rimrafSync('styles/**/*.css', {glob: true});
done();
});

Expand Down
17 changes: 17 additions & 0 deletions playwright/playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
import React from 'react';

import {beforeMount} from '@playwright/experimental-ct-react/hooks';

import {MobileProvider} from '../../src/components/mobile/MobileProvider';
import {ThemeProvider} from '../../src/components/theme/ThemeProvider';

import './index.scss';

beforeMount(async ({App}) => {
return (
<ThemeProvider theme="light">
<MobileProvider>
<App />
</MobileProvider>
</ThemeProvider>
);
});
3 changes: 3 additions & 0 deletions src/components/Table/__stories__/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ const WithTableActionsTemplate: StoryFn<TableProps<DataItem>> = (args) => {
);
};
export const HOCWithTableActions = WithTableActionsTemplate.bind({});
HOCWithTableActions.args = {
onRowClick: () => action('default')('click'),
};

// ---------------------------------
const columnsWithCopy = _cloneDeep(columns);
Expand Down
36 changes: 35 additions & 1 deletion src/components/Table/__tests__/Table.hocs.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';

import {render} from '../../../../test-utils/utils';
import userEvent from '@testing-library/user-event';

import {render, screen, within} from '../../../../test-utils/utils';
import type {TableProps} from '../Table';
import {Table} from '../Table';
import type {
Expand Down Expand Up @@ -47,6 +49,38 @@ describe('Table HOCs tests', () => {
expect(getTextContent(container1.outerHTML)).toEqual(getTextContent(container2.outerHTML));
});

it('using withTableActions with onRowClick should not click on row when clicking on menu item', async () => {
const TableWithActions = withTableActions<Model>(Table);

type Props = TableProps<Model> & WithTableActionsProps<Model>;
const user = userEvent.setup();
const onRowClick = jest.fn();
const onMenuItemClick = jest.fn();
const props: Props = {
data: [{disabled: false}],
columns: [{id: 'name'}],
onRowClick,
getRowActions: () => [
{
text: 'event',
handler: onMenuItemClick,
},
],
};

render(React.createElement<Props>(TableWithActions, props));

const table = screen.getByRole('table');
const menuButton = within(table).getAllByRole('button');
await user.click(menuButton[0]);
const menuItem = screen.getByRole('menuitem');
expect(menuItem).toBeInTheDocument();
await user.click(menuItem);

expect(onMenuItemClick).toHaveBeenCalledTimes(props.data.length);
expect(onRowClick).toHaveBeenCalledTimes(0);
});

it('using withTableActions and withTableSorting should not depend of order', () => {
const Table1 = withTableActions(withTableSorting<Model>(Table));
const Table2 = withTableSorting(withTableActions<Model>(Table));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ const DefaultRowActions = <I extends TableDataItem>({
return (
<Menu.Item
key={index}
onClick={(event) => handler(item, index, event)}
onClick={(event) => {
event.stopPropagation();
handler(item, index, event);
}}
iconStart={icon}
className={menuItemCn}
{...restProps}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toc/__stories__/Toc.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import './Toc.stories.scss';
const b = block('toc-stories');

export default {
title: 'Components/Data Display/Toc',
title: 'Components/Navigation/Toc',
component: Toc,
argTypes: {},
} as Meta;
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ export * from './utils/event-broker';
export {getComponentName} from './utils/getComponentName';
export * from './utils/withEventBrokerDomHandlers';
export * from './utils/layer-manager';
export {Lang, configure} from './utils/configure';
export {Lang, configure, getConfig} from './utils/configure';
export * from './utils/xpath';
export {getUniqId} from './utils/common';
18 changes: 9 additions & 9 deletions src/components/theme/dom-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ export function updateBodyClassName({
bodyEl.classList.add(rootClassName);
}

if (className) {
const parsedCustomRootClassNames = className.split(' ');
parsedCustomRootClassNames.forEach((cls) => {
if (cls && !bodyEl.classList.contains(cls)) {
bodyEl.classList.add(cls);
}
});
}

if (prevClassName) {
const parsedPrevCustomRootClassNames = prevClassName.split(' ');
parsedPrevCustomRootClassNames.forEach((cls) => {
Expand All @@ -41,6 +32,15 @@ export function updateBodyClassName({
});
}

if (className) {
const parsedCustomRootClassNames = className.split(' ');
parsedCustomRootClassNames.forEach((cls) => {
if (cls && !bodyEl.classList.contains(cls)) {
bodyEl.classList.add(cls);
}
});
}

[...bodyEl.classList].forEach((cls) => {
if (cls.startsWith(modsClassName(b({theme: true})))) {
bodyEl.classList.remove(cls);
Expand Down

0 comments on commit a5fe96b

Please sign in to comment.