, and we end up with nested
+ // interactive elements
+
+ onClickItem()}>{actionControl}
+
+ );
+ } else {
+ const {
+ onClick,
+ name,
+ href,
+ target,
+ 'data-test-subj': dataTestSubj,
+ } = action;
+
+ const buttonIcon = action.icon;
+ let icon;
+ if (buttonIcon) {
+ icon = isString(buttonIcon) ? buttonIcon : buttonIcon(item);
}
- return controls;
- },
- []
- );
-
- const popoverButton = (
-
- {(allActions: string) => (
-
- )}
-
- );
-
- const withTooltip = !allDisabled && (
-
- {(allActions: ReactNode) => (
-
- {popoverButton}
-
- )}
-
- );
-
- return (
-
-
-
- );
- }
-}
+ const buttonContent = typeof name === 'function' ? name(item) : name;
+
+ controls.push(
+
+ onClickItem(onClick ? () => onClick(item) : undefined)
+ }
+ >
+ {buttonContent}
+
+ );
+ }
+ return controls;
+ }, []);
+ }, [actions, actionEnabled, item, onClickItem]);
+
+ const popoverButton = (
+
+ {(allActions: string) => (
+ setPopoverOpen((isOpen) => !isOpen)}
+ data-test-subj="euiCollapsedItemActionsButton"
+ />
+ )}
+
+ );
+
+ const withTooltip = !allDisabled && (
+
+ {(allActions: ReactNode) => (
+
+ {popoverButton}
+
+ )}
+
+ );
+
+ return (
+
setPopoverOpen(false)}
+ panelPaddingSize="none"
+ anchorPosition="leftCenter"
+ >
+
+
+ );
+};
diff --git a/src/components/basic_table/custom_item_action.tsx b/src/components/basic_table/custom_item_action.tsx
index 9236e9ac693..91351d5efbd 100644
--- a/src/components/basic_table/custom_item_action.tsx
+++ b/src/components/basic_table/custom_item_action.tsx
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import React, { Component, cloneElement } from 'react';
+import React from 'react';
import { CustomItemAction as Action } from './action_types';
export interface CustomItemActionProps
{
@@ -17,66 +17,11 @@ export interface CustomItemActionProps {
index?: number;
}
-interface CustomItemActionState {
- hasFocus: boolean;
-}
-
-export class CustomItemAction extends Component<
- CustomItemActionProps,
- CustomItemActionState
-> {
- private mounted: boolean;
-
- constructor(props: CustomItemActionProps) {
- super(props);
- this.state = { hasFocus: false };
-
- // while generally considered an anti-pattern, here we require
- // to do that as the onFocus/onBlur events of the action controls
- // may trigger while this component is unmounted. An alternative
- // (at least the workarounds suggested by react is to unregister
- // the onFocus/onBlur listeners from the action controls... this
- // unfortunately will lead to unnecessarily complex code... so we'll
- // stick to this approach for now)
- this.mounted = false;
- }
-
- componentDidMount() {
- this.mounted = true;
- }
-
- componentWillUnmount() {
- this.mounted = false;
- }
-
- onFocus = () => {
- if (this.mounted) {
- this.setState({ hasFocus: true });
- }
- };
-
- onBlur = () => {
- if (this.mounted) {
- this.setState({ hasFocus: false });
- }
- };
-
- hasFocus = () => {
- return this.state.hasFocus;
- };
-
- render() {
- const { action, enabled, item, className } = this.props;
- const tool = action.render(item, enabled);
- const clonedTool = cloneElement(tool, {
- onFocus: this.onFocus,
- onBlur: this.onBlur,
- });
- const style = this.hasFocus() ? { opacity: 1 } : undefined;
- return (
-
- {clonedTool}
-
- );
- }
-}
+export const CustomItemAction = ({
+ action,
+ enabled,
+ item,
+ className,
+}: CustomItemActionProps) => (
+ {action.render(item, enabled)}
+);
diff --git a/src/components/table/_responsive.scss b/src/components/table/_responsive.scss
index 58f8950e89d..5b11913459f 100644
--- a/src/components/table/_responsive.scss
+++ b/src/components/table/_responsive.scss
@@ -99,6 +99,25 @@
}
}
+ // Custom actions
+ &:not(.euiTableRow-hasActions) .euiTableRowCell--hasActions:last-child {
+ width: 100%;
+
+ &::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ right: 0;
+ height: $euiBorderWidthThin;
+ background-color: $euiTableActionsBorderColor;
+ }
+
+ .euiTableCellContent {
+ position: relative;
+ top: $euiSizeXS;
+ }
+ }
+
&.euiTableRow-hasActions.euiTableRow-isExpandable {
.euiTableRowCell--isExpander {
top: auto;