Skip to content

Commit 80324af

Browse files
authored
fix(VariantManagement): fix delete button alignment & pop-in behavior (#7496)
Fixes #7476
1 parent 13dc7a4 commit 80324af

File tree

5 files changed

+36
-33
lines changed

5 files changed

+36
-33
lines changed

packages/main/src/components/VariantManagement/ManageViewsDialog.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import { Bar } from '../../webComponents/Bar/index.js';
2323
import { Button } from '../../webComponents/Button/index.js';
2424
import type { DialogPropTypes } from '../../webComponents/Dialog/index.js';
2525
import { Dialog } from '../../webComponents/Dialog/index.js';
26-
import type { InputDomRef } from '../../webComponents/index.js';
27-
import { Icon, Input } from '../../webComponents/index.js';
26+
import { Icon } from '../../webComponents/Icon/index.js';
27+
import type { InputDomRef } from '../../webComponents/Input/index.js';
28+
import { Input } from '../../webComponents/Input/index.js';
2829
import { Table } from '../../webComponents/Table/index.js';
30+
import type { TablePropTypes } from '../../webComponents/Table/index.js';
2931
import { TableHeaderCell } from '../../webComponents/TableHeaderCell/index.js';
3032
import { TableHeaderRow } from '../../webComponents/TableHeaderRow/index.js';
3133
import { FlexBox } from '../FlexBox/index.js';
@@ -90,7 +92,7 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
9092
const headerRow = (
9193
<TableHeaderRow sticky>
9294
{showOnlyFavorites && <TableHeaderCell key="favorite-variant-item" />}
93-
<TableHeaderCell importance={10} min-width="18rem">
95+
<TableHeaderCell importance={10} minWidth="14rem">
9496
{viewHeaderText}
9597
</TableHeaderCell>
9698
{showShare && (
@@ -104,12 +106,11 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
104106
</TableHeaderCell>
105107
)}
106108
{showApplyAutomatically && (
107-
<TableHeaderCell minWidth={hasApplyAutomaticallyText ? '25rem' : '5rem'}>
109+
<TableHeaderCell minWidth={hasApplyAutomaticallyText ? '12.5rem' : '5rem'}>
108110
{applyAutomaticallyHeaderText}
109111
</TableHeaderCell>
110112
)}
111-
{showCreatedBy && <TableHeaderCell minWidth="10rem">{createdByHeaderText}</TableHeaderCell>}
112-
<TableHeaderCell importance={9} width="3rem" key="delete-variant-item" />
113+
{showCreatedBy && <TableHeaderCell minWidth="7.125rem">{createdByHeaderText}</TableHeaderCell>}
113114
</TableHeaderRow>
114115
);
115116

@@ -155,11 +156,12 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
155156
}
156157
};
157158
const deletedTableRows = useRef(new Set([]));
158-
const handleDelete = (e) => {
159-
deletedTableRows.current.add(e.target.dataset.children);
159+
const handleDelete: TablePropTypes['onRowActionClick'] = (e) => {
160+
const variantChild = e.detail.row.dataset.id;
161+
deletedTableRows.current.add(variantChild);
160162
setChildrenProps((prev) =>
161163
prev
162-
.filter((item) => item.children !== e.target.dataset.children)
164+
.filter((item) => item.children !== variantChild)
163165
.map((item) => {
164166
if (Object.prototype.hasOwnProperty.call(changedTableRows.current, item.children)) {
165167
return { ...item, ...changedTableRows.current[item.children] };
@@ -260,7 +262,12 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
260262
/>
261263
}
262264
>
263-
<Table headerRow={headerRow} role="table" overflowMode={TableOverflowMode.Popin}>
265+
<Table
266+
headerRow={headerRow}
267+
overflowMode={TableOverflowMode.Popin}
268+
rowActionCount={1}
269+
onRowActionClick={handleDelete}
270+
>
264271
{filteredProps.map((itemProps) => {
265272
return (
266273
<ManageViewsTableRows
@@ -270,7 +277,6 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
270277
changedVariantNames={changedVariantNames}
271278
variantNames={variantNames}
272279
handleRowChange={handleTableRowChange}
273-
handleDelete={handleDelete}
274280
defaultView={defaultView}
275281
setDefaultView={setDefaultView}
276282
showShare={showShare}

packages/main/src/components/VariantManagement/ManageViewsTableRows.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
21
import IconMode from '@ui5/webcomponents/dist/types/IconMode.js';
32
import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js';
43
import declineIcon from '@ui5/webcomponents-icons/dist/decline.js';
@@ -20,14 +19,19 @@ import {
2019
VIEW,
2120
} from '../../i18n/i18n-defaults.js';
2221
import { trimAndRemoveSpaces } from '../../internal/utils.js';
23-
import { Button, CheckBox, Icon, Input, RadioButton, TableCell, TableRow } from '../../webComponents/index.js';
22+
import { CheckBox } from '../../webComponents/CheckBox/index.js';
23+
import { Icon } from '../../webComponents/Icon/index.js';
24+
import { Input } from '../../webComponents/Input/index.js';
25+
import { RadioButton } from '../../webComponents/RadioButton/index.js';
26+
import { TableCell } from '../../webComponents/TableCell/index.js';
27+
import { TableRow } from '../../webComponents/TableRow/index.js';
28+
import { TableRowAction } from '../../webComponents/TableRowAction/index.js';
2429
import { Text } from '../../webComponents/Text/index.js';
2530
import type { VariantItemPropTypes } from './VariantItem.js';
2631

2732
interface ManageViewsTableRowsProps extends Partial<VariantItemPropTypes> {
2833
variantNames: string[];
2934
handleRowChange: (e: Event, payload: any) => void;
30-
handleDelete: (e: any) => void;
3135
defaultView: string;
3236
setDefaultView: (view: string) => void;
3337
showShare: boolean;
@@ -46,7 +50,6 @@ export const ManageViewsTableRows = (props: ManageViewsTableRowsProps) => {
4650
changedVariantNames,
4751
setChangedVariantNames,
4852
handleRowChange,
49-
handleDelete,
5053
defaultView,
5154
setDefaultView,
5255
showShare,
@@ -170,7 +173,11 @@ export const ManageViewsTableRows = (props: ManageViewsTableRowsProps) => {
170173
);
171174
};
172175
return (
173-
<TableRow data-id={children} key={`${children}`}>
176+
<TableRow
177+
data-id={children}
178+
key={`${children}`}
179+
actions={!(hideDelete ?? global) && <TableRowAction icon={declineIcon} text={a11yDeleteText} />}
180+
>
174181
{showOnlyFavorites && (
175182
<TableCell>
176183
{isDefault ? (
@@ -213,18 +220,6 @@ export const ManageViewsTableRows = (props: ManageViewsTableRowsProps) => {
213220
<Text>{author}</Text>
214221
</TableCell>
215222
)}
216-
<TableCell>
217-
{!(hideDelete ?? global) && (
218-
<Button
219-
tooltip={a11yDeleteText}
220-
accessibleName={a11yDeleteText}
221-
icon={declineIcon}
222-
design={ButtonDesign.Transparent}
223-
onClick={handleDelete}
224-
data-children={children}
225-
/>
226-
)}
227-
</TableCell>
228223
</TableRow>
229224
);
230225
};

packages/main/src/components/VariantManagement/VariantManagement.cy.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,12 @@ describe('VariantManagement', () => {
667667
cy.get('[icon="navigation-down-arrow"]').click();
668668
cy.findByText('Manage').click();
669669

670-
cy.get('[ui5-button][tooltip="Delete View"]').each(($btn) => {
671-
if ($btn[0].getAttribute('data-children') !== 'VariantItem 3') {
672-
cy.wrap($btn).click();
670+
cy.get('[ui5-table-row-action][text="Delete View"]').each(($action) => {
671+
if ($action.parent().attr('data-id') !== 'VariantItem 3') {
672+
cy.wrap($action).click();
673673
}
674674
});
675+
675676
cy.findByText('Save').click();
676677
cy.get('@saveView').should('have.been.calledOnce');
677678
cy.findByText(

packages/main/src/components/VariantManagement/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ const VariantManagement = forwardRef<HTMLDivElement, VariantManagementPropTypes>
251251
}
252252
if (deletedRows.has(castChild.props.children)) {
253253
callbackProperties.deletedVariants.push(castChild.props);
254+
deletedRows.delete(castChild.props.children);
254255
return false;
255256
}
256257
if (Object.keys(updatedProps).length > 0) {

packages/main/src/webComponents/Table/Table.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ export const withRowActions: Story = {
297297
key={`${row.name}-${row.age}`}
298298
actions={
299299
<>
300-
<TableRowAction icon={editIcon}>Edit</TableRowAction>
301-
<TableRowAction icon={saveIcon}>Save</TableRowAction>
300+
<TableRowAction icon={editIcon} text="Edit" />
301+
<TableRowAction icon={saveIcon} text="Save" />
302302
<TableRowActionNavigation interactive={!!(index % 2)} />
303303
</>
304304
}

0 commit comments

Comments
 (0)