Skip to content

Commit

Permalink
Merge branch 'main' into storybook/7481-stories-p
Browse files Browse the repository at this point in the history
  • Loading branch information
mgadewoll authored Apr 11, 2024
2 parents ecb2221 + 9b0e1da commit 3069f38
Show file tree
Hide file tree
Showing 33 changed files with 514 additions and 204 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/lifecycle/pre_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export GCE_ACCOUNT
GITHUB_TOKEN=$(retry 5 vault read -field=github_token $GITHUB_ACCOUNT)
export GITHUB_TOKEN

DOCKER_BASE_IMAGE=docker.elastic.co/eui/ci:6.3
DOCKER_BASE_IMAGE=docker.elastic.co/eui/ci:6.4
export DOCKER_BASE_IMAGE

GCE_IMAGE=google/cloud-sdk:slim
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
20.12.1
5 changes: 5 additions & 0 deletions changelogs/CHANGELOG_2024.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [`v94.1.0`](https://github.com/elastic/eui/releases/v94.1.0)

- Updated `EuiTableHeaderCell` to show a subdued `sortable` icon for columns that are not currently sorted but can be ([#7656](https://github.com/elastic/eui/pull/7656))
- Updated `EuiBasicTable` and `EuiInMemoryTable`'s `columns[].actions[]`'s to pass back click events to `onClick` callbacks as the second callback ([#7667](https://github.com/elastic/eui/pull/7667))

## [`v94.0.0`](https://github.com/elastic/eui/releases/v94.0.0)

- Updated `EuiTable`, `EuiBasicTable`, and `EuiInMemoryTable` with a new `responsiveBreakpoint` prop, which allows customizing the point at which the table collapses into a mobile-friendly view with cards ([#7625](https://github.com/elastic/eui/pull/7625))
Expand Down
3 changes: 3 additions & 0 deletions changelogs/upcoming/7599.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Dependency updates**

- Updated `@hello-pangea/dnd` to v16.6.0
6 changes: 6 additions & 0 deletions changelogs/upcoming/7666.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**Bug fixes**

- Fixed `EuiFieldNumber`'s typing to accept an icon configuration shape
- Fixed `EuiFieldText` and `EuiFieldNumber` to render the correct paddings for icon shapes set to `side: 'right'`
- Fixed `EuiFieldText` and `EuiFieldNumber` to fully ignore `icon`/`prepend`/`append` when `controlOnly` is set to true
- Fixed `EuiColorPicker`'s input not setting the correct right padding for the number of icons displayed
28 changes: 14 additions & 14 deletions i18ntokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@
"highlighting": "string",
"loc": {
"start": {
"line": 115,
"line": 110,
"column": 4,
"index": 3600
"index": 3586
},
"end": {
"line": 124,
"line": 119,
"column": 5,
"index": 3867
"index": 3853
}
},
"filepath": "src/components/basic_table/collapsed_item_actions.tsx"
Expand All @@ -185,14 +185,14 @@
"highlighting": "string",
"loc": {
"start": {
"line": 115,
"line": 110,
"column": 4,
"index": 3600
"index": 3586
},
"end": {
"line": 124,
"line": 119,
"column": 5,
"index": 3867
"index": 3853
}
},
"filepath": "src/components/basic_table/collapsed_item_actions.tsx"
Expand All @@ -203,14 +203,14 @@
"highlighting": "string",
"loc": {
"start": {
"line": 141,
"line": 136,
"column": 4,
"index": 4427
"index": 4413
},
"end": {
"line": 141,
"line": 136,
"column": 78,
"index": 4501
"index": 4487
}
},
"filepath": "src/components/basic_table/collapsed_item_actions.tsx"
Expand Down Expand Up @@ -6595,12 +6595,12 @@
"start": {
"line": 77,
"column": 10,
"index": 2366
"index": 2359
},
"end": {
"line": 81,
"column": 11,
"index": 2540
"index": 2533
}
},
"filepath": "src/components/table/table_header_cell.tsx"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@elastic/eui",
"description": "Elastic UI Component Library",
"version": "94.0.0",
"version": "94.1.0",
"license": "SEE LICENSE IN LICENSE.txt",
"main": "lib",
"module": "es",
"types": "eui.d.ts",
"docker_image": "20.11.1",
"docker_image": "20.12.1",
"engines": {
"node": "16.x || 18.x || >=20.x"
},
Expand Down Expand Up @@ -58,7 +58,7 @@
"test-staged"
],
"dependencies": {
"@hello-pangea/dnd": "^16.3.0",
"@hello-pangea/dnd": "^16.6.0",
"@types/lodash": "^4.14.202",
"@types/numeral": "^2.0.5",
"@types/react-window": "^1.8.8",
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zenato/docker-puppeteer/blob/master/Dockerfile

# >=12.0 required (for cypress). v18 is LTS.
FROM --platform=linux/amd64 node:20.11.1-slim
FROM --platform=linux/amd64 node:20.12.1-slim

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down
9 changes: 0 additions & 9 deletions scripts/docker-ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Built containers can be published to the [Elastic Docker Registry](https://conta

## Getting started

### `test-docker` script
The [`test-docker`](../test-docker.js) script is the primary user of this container. Specifically, the [`a11y-testing`](../a11y-testing.js) script therein uses the headless Chromium environment to run EUI's automated axe accessibility testing suite.

### Generic node application
Run the container by passing `node -e "<yourscript.js content as a string>"` as the command:

Expand Down Expand Up @@ -37,10 +34,6 @@ docker build [--no-cache] [--tag ci:x.x] .
> :warning: If you receive a `Cannot connect to Docker daemon` error, you can use [Docker Desktop](https://docs.docker.com/desktop/#download-and-install) (without signing in). Simply starting the app will create the Docker engine/daemon needed.

### Test a new image locally

To run the [`test-docker`](../test-docker.js) script with the new image locally, you'll need to replace the image name line in the `docker run ...` command (`docker.elastic.co/eui/ci:x.x`) with the new image ID or tag name (if set during the build with `--tag`).

### Publish a built image

Authentication and membership of the `eui-team` team on GitHub is required:
Expand Down Expand Up @@ -76,5 +69,3 @@ docker pull docker.elastic.co/eui/ci:x.x

docker run [...]
```

See the [`test-docker`](../test-docker.js) script as an example.
1 change: 1 addition & 0 deletions src-docs/src/components/guide_page/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"euiVersions": [
"94.1.0",
"94.0.0",
"93.6.0",
"93.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
</div>
</th>
<th
aria-live="polite"
aria-sort="ascending"
class="euiTableHeaderCell emotion-euiTableHeaderCell"
data-test-subj="tableHeaderCell_name_0"
Expand Down
8 changes: 5 additions & 3 deletions src/components/basic_table/action_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { ReactElement, ReactNode } from 'react';
import { ReactElement, ReactNode, MouseEvent } from 'react';
import { EuiIconType } from '../icon/icon';
import { EuiButtonIconProps } from '../button/button_icon/button_icon';
import { EuiButtonEmptyProps } from '../button/button_empty';
Expand All @@ -26,9 +26,11 @@ export interface DefaultItemActionBase<T extends object> {
*/
description: string | ((item: T) => string);
/**
* A handler function to execute the action
* A handler function to execute the action. Passes back the current row
* item as the first argument, and the originating React click event
* as a second argument.
*/
onClick?: (item: T) => void;
onClick?: (item: T, event: MouseEvent) => void;
href?: string | ((item: T) => string);
target?: string;
/**
Expand Down
42 changes: 42 additions & 0 deletions src/components/basic_table/collapsed_item_actions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,48 @@ describe('CollapsedItemActions', () => {
await waitForEuiPopoverClose();
});

test('default actions - passes back the original click event as well as the row item to onClick', async () => {
const onClick = jest.fn();
const onClickStopPropagation = jest.fn((item, event) => {
event.stopPropagation();
});

const props = {
actions: [
{
name: '1',
description: '',
onClick,
'data-test-subj': 'onClick',
},
{
name: '2',
description: '',
onClick: onClickStopPropagation,
'data-test-subj': 'onClickStopPropagation',
},
],
itemId: 'id',
item: { id: 'xyz' },
actionsDisabled: false,
};

const { getByTestSubject } = render(<CollapsedItemActions {...props} />);
fireEvent.click(getByTestSubject('euiCollapsedItemActionsButton'));
await waitForEuiPopoverOpen();

fireEvent.click(getByTestSubject('onClickStopPropagation'));
expect(onClickStopPropagation).toHaveBeenCalledWith(
props.item,
expect.objectContaining({ stopPropagation: expect.any(Function) })
);
// Popover should still be open if propagation was stopped
await waitForEuiPopoverOpen();

fireEvent.click(getByTestSubject('onClick'));
await waitForEuiPopoverClose();
});

test('custom actions', async () => {
const props = {
actions: [
Expand Down
31 changes: 13 additions & 18 deletions src/components/basic_table/collapsed_item_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React, {
ReactElement,
} from 'react';

import { isString } from '../../services/predicate';
import { EuiContextMenuItem, EuiContextMenuPanel } from '../context_menu';
import { EuiPopover } from '../popover';
import { EuiButtonIcon } from '../button';
Expand Down Expand Up @@ -45,11 +44,7 @@ export const CollapsedItemActions = <T extends {}>({
className,
}: CollapsedItemActionsProps<T>) => {
const [popoverOpen, setPopoverOpen] = useState(false);

const onClickItem = useCallback((onClickAction?: () => void) => {
setPopoverOpen(false);
onClickAction?.();
}, []);
const closePopover = useCallback(() => setPopoverOpen(false), []);

const controls = useMemo(() => {
return actions.reduce<ReactElement[]>((controls, action, index) => {
Expand All @@ -69,16 +64,13 @@ export const CollapsedItemActions = <T extends {}>({
key={index}
className="euiBasicTable__collapsedCustomAction"
>
<span onClick={() => onClickItem()}>{actionControl}</span>
<span onClick={closePopover}>{actionControl}</span>
</EuiContextMenuItem>
);
} else {
const buttonIcon = action.icon;
let icon;
if (buttonIcon) {
icon = isString(buttonIcon) ? buttonIcon : buttonIcon(item);
}

const icon = action.icon
? callWithItemIfFunction(item)(action.icon)
: undefined;
const buttonContent = callWithItemIfFunction(item)(action.name);
const toolTipContent = callWithItemIfFunction(item)(action.description);
const href = callWithItemIfFunction(item)(action.href);
Expand All @@ -97,9 +89,12 @@ export const CollapsedItemActions = <T extends {}>({
target={target}
icon={icon}
data-test-subj={dataTestSubj}
onClick={() =>
onClickItem(onClick ? () => onClick(item) : undefined)
}
onClick={(event) => {
event.persist();
onClick?.(item, event);
// Allow consumer events to prevent the popover from closing if necessary
if (!event.isPropagationStopped()) closePopover();
}}
toolTipContent={toolTipContent}
toolTipProps={{ delay: 'long' }}
>
Expand All @@ -109,7 +104,7 @@ export const CollapsedItemActions = <T extends {}>({
}
return controls;
}, []);
}, [actions, actionsDisabled, item, onClickItem]);
}, [actions, actionsDisabled, item, closePopover]);

const popoverButton = (
<EuiI18n
Expand Down Expand Up @@ -153,7 +148,7 @@ export const CollapsedItemActions = <T extends {}>({
id={`${itemId}-actions`}
isOpen={popoverOpen}
button={withTooltip || popoverButton}
closePopover={() => setPopoverOpen(false)}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="leftCenter"
>
Expand Down
26 changes: 26 additions & 0 deletions src/components/basic_table/default_item_action.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,30 @@ describe('DefaultItemAction', () => {
await waitForEuiToolTipVisible();
expect(getByText('goodbye tooltip')).toBeInTheDocument();
});

it('passes back the original click event as well as the row item to onClick', () => {
const onClick = jest.fn((item, event) => {
event.preventDefault();
});

const action: EmptyButtonAction<Item> = {
name: 'onClick',
description: 'test',
onClick,
'data-test-subj': 'onClick',
};
const props = {
action,
enabled: true,
item: { id: 'xyz' },
};

const { getByTestSubject } = render(<DefaultItemAction {...props} />);

fireEvent.click(getByTestSubject('onClick'));
expect(onClick).toHaveBeenCalledWith(
props.item,
expect.objectContaining({ preventDefault: expect.any(Function) })
);
});
});
Loading

0 comments on commit 3069f38

Please sign in to comment.