@@ -2,7 +2,10 @@ import BarDesign from '@ui5/webcomponents/dist/types/BarDesign.js';
22import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js' ;
33import TableOverflowMode from '@ui5/webcomponents/dist/types/TableOverflowMode.js' ;
44import { getScopedVarName } from '@ui5/webcomponents-base/dist/CustomElementsScope.js' ;
5+ import { isPhone as getIsPhone } from '@ui5/webcomponents-base/dist/Device.js' ;
6+ import NoEntriesIllu from '@ui5/webcomponents-fiori/dist/illustrations/NoEntries.js' ;
57import searchIcon from '@ui5/webcomponents-icons/dist/search.js' ;
8+ import type { Ui5DomRef } from '@ui5/webcomponents-react-base' ;
69import { enrichEventWithDetails , useI18nBundle , useStylesheet } from '@ui5/webcomponents-react-base' ;
710import type { MouseEventHandler , ReactElement } from 'react' ;
811import { Children , isValidElement , useEffect , useId , useRef , useState } from 'react' ;
@@ -13,6 +16,8 @@ import {
1316 CANCEL ,
1417 CREATED_BY ,
1518 DEFAULT ,
19+ NO_VIEWS_DEFINED_TITLE ,
20+ NO_VIEWS_DEFINED_SUBTITLE ,
1621 MANAGE_VIEWS ,
1722 SAVE ,
1823 SEARCH ,
@@ -22,15 +27,18 @@ import {
2227import type { CommonProps } from '../../types/CommonProps.js' ;
2328import { Bar } from '../../webComponents/Bar/index.js' ;
2429import { Button } from '../../webComponents/Button/index.js' ;
30+ import type { ButtonDomRef } from '../../webComponents/Button/index.js' ;
2531import type { DialogPropTypes } from '../../webComponents/Dialog/index.js' ;
2632import { Dialog } from '../../webComponents/Dialog/index.js' ;
2733import { Icon } from '../../webComponents/Icon/index.js' ;
34+ import { IllustratedMessage } from '../../webComponents/IllustratedMessage/index.js' ;
2835import type { InputDomRef } from '../../webComponents/Input/index.js' ;
2936import { Input } from '../../webComponents/Input/index.js' ;
3037import { Table } from '../../webComponents/Table/index.js' ;
31- import type { TablePropTypes } from '../../webComponents/Table/index.js' ;
38+ import type { TableDomRef , TablePropTypes } from '../../webComponents/Table/index.js' ;
3239import { TableHeaderCell } from '../../webComponents/TableHeaderCell/index.js' ;
3340import { TableHeaderRow } from '../../webComponents/TableHeaderRow/index.js' ;
41+ import type { TableRowDomRef } from '../../webComponents/TableRow/index.js' ;
3442import { FlexBox } from '../FlexBox/index.js' ;
3543import type { VariantItemPropTypes } from '../VariantItem/index.js' ;
3644import { classNames , styleData } from './ManageViewsDialog.module.css.js' ;
@@ -59,6 +67,8 @@ export interface ManageViewsDialogPropTypes {
5967 onManageViewsCancel ?: VariantManagementPropTypes [ 'onManageViewsCancel' ] ;
6068}
6169
70+ const isPhone = getIsPhone ( ) ;
71+
6272export const ManageViewsDialog = ( props : ManageViewsDialogPropTypes ) => {
6373 const {
6474 children,
@@ -74,6 +84,8 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
7484 } = props ;
7585 const uniqueId = useId ( ) ;
7686 const i18nBundle = useI18nBundle ( '@ui5/webcomponents-react' ) ;
87+ const tableRef = useRef < TableDomRef > ( null ) ;
88+ const cancelBtnRef = useRef < ButtonDomRef > ( null ) ;
7789 const cancelText = i18nBundle . getText ( CANCEL ) ;
7890 const saveText = i18nBundle . getText ( SAVE ) ;
7991 const viewHeaderText = i18nBundle . getText ( VIEW ) ;
@@ -158,18 +170,21 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
158170 } ;
159171 const deletedTableRows = useRef ( new Set ( [ ] ) ) ;
160172 const handleDelete : TablePropTypes [ 'onRowActionClick' ] = ( e ) => {
161- const variantChild = e . detail . row . dataset . id ;
173+ const { nextElementSibling, previousElementSibling, dataset } = e . detail . row ;
174+ const variantChild = dataset . id ;
175+
162176 deletedTableRows . current . add ( variantChild ) ;
163- setChildrenProps ( ( prev ) =>
164- prev
165- . filter ( ( item ) => item . children !== variantChild )
166- . map ( ( item ) => {
167- if ( Object . prototype . hasOwnProperty . call ( changedTableRows . current , item . children ) ) {
168- return { ...item , ...changedTableRows . current [ item . children ] } ;
169- }
170- return item ;
171- } ) ,
172- ) ;
177+ let nextFocusElement : Ui5DomRef | null = null ;
178+ if ( nextElementSibling ?. hasAttribute ( 'ui5-table-row' ) ) {
179+ nextFocusElement = nextElementSibling as TableRowDomRef ;
180+ } else if ( previousElementSibling ?. hasAttribute ( 'ui5-table-row' ) ) {
181+ nextFocusElement = previousElementSibling as TableRowDomRef ;
182+ } else {
183+ nextFocusElement = cancelBtnRef . current ;
184+ }
185+ void nextFocusElement ?. focus ( ) ;
186+
187+ setChildrenProps ( ( prev ) => prev . filter ( ( item ) => item . children !== variantChild ) ) ;
173188 } ;
174189
175190 const handleSave = ( e ) => {
@@ -222,6 +237,7 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
222237 return (
223238 < Dialog
224239 open
240+ stretch = { isPhone }
225241 className = { classNames . manageViewsDialog }
226242 data-component-name = "VariantManagementManageViewsDialog"
227243 onClose = { onAfterClose }
@@ -255,7 +271,7 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
255271 < Button design = { ButtonDesign . Emphasized } onClick = { handleSave } >
256272 { saveText }
257273 </ Button >
258- < Button design = { ButtonDesign . Transparent } onClick = { handleCancel } >
274+ < Button design = { ButtonDesign . Transparent } onClick = { handleCancel } ref = { cancelBtnRef } >
259275 { cancelText }
260276 </ Button >
261277 </ >
@@ -264,10 +280,19 @@ export const ManageViewsDialog = (props: ManageViewsDialogPropTypes) => {
264280 }
265281 >
266282 < Table
283+ ref = { tableRef }
267284 headerRow = { headerRow }
268285 overflowMode = { TableOverflowMode . Popin }
269286 rowActionCount = { 1 }
270287 onRowActionClick = { handleDelete }
288+ noData = {
289+ < IllustratedMessage
290+ name = { NoEntriesIllu }
291+ design = { 'Medium' }
292+ titleText = { i18nBundle . getText ( NO_VIEWS_DEFINED_TITLE ) }
293+ subtitleText = { i18nBundle . getText ( NO_VIEWS_DEFINED_SUBTITLE ) }
294+ />
295+ }
271296 >
272297 { filteredProps . map ( ( itemProps ) => {
273298 return (
0 commit comments