diff --git a/src/shared/contexts/NotificationContext.tsx b/src/shared/contexts/NotificationContext.tsx index afc1f45654..ad20dd28aa 100644 --- a/src/shared/contexts/NotificationContext.tsx +++ b/src/shared/contexts/NotificationContext.tsx @@ -1,5 +1,5 @@ -import { MessageStrip } from '@ui5/webcomponents-react'; -import { createContext, useContext, useState } from 'react'; +import { Toast, ToastDomRef } from '@ui5/webcomponents-react'; +import { createContext, useContext, useRef, useState } from 'react'; import { ErrorModal, ErrorModalProps, @@ -23,28 +23,23 @@ type NotificationContextArgs = { export const NotificationContext = createContext({ isOpen: false, - notifySuccess: props => {}, - notifyError: props => {}, + notifySuccess: () => {}, + notifyError: () => {}, }); export const NotificationProvider = ({ children, - defaultVisibilityTime = 5000, + defaultVisibilityTime = 3000, }: NotificationContextProps) => { const [toastProps, setToastProps] = useState(); const [errorProps, setErrorProps] = useState(); + const toast = useRef(null); + const methods = { - notifySuccess: function( - notificationProps: ToastProps, - visibilityTime: number = defaultVisibilityTime, - ) { - if (visibilityTime !== 0) { - setTimeout(() => { - setToastProps(null); - }, visibilityTime); - } + notifySuccess: function(notificationProps: ToastProps) { setToastProps(notificationProps); + toast.current?.show(); }, notifyError: function(notificationProps: Omit) { setErrorProps({ @@ -61,16 +56,9 @@ export const NotificationProvider = ({ ...methods, }} > - {toastProps && ( -
setToastProps(null)} - > - - {toastProps.content} - -
- )} + + {toastProps?.content} + {errorProps && createPortal(, document.body)} {children} diff --git a/src/styles/index.scss b/src/styles/index.scss index a13b1763c3..f29ca2b469 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -127,16 +127,6 @@ ui5-tabcontainer::part(content) { font-style: normal; } -.message-toast--wrapper { - position: fixed; - transition: all ease-in-out 0.4s; - z-index: 1100; - cursor: pointer; - left: 50vw; - transform: translateX(-50%); - bottom: 50px; -} - .flexwrap { display: flex; flex-wrap: wrap; diff --git a/tests/integration/support/commands.js b/tests/integration/support/commands.js index b4169489c7..9148442a90 100644 --- a/tests/integration/support/commands.js +++ b/tests/integration/support/commands.js @@ -189,8 +189,6 @@ Cypress.Commands.add( cy.contains('ui5-link', resourceName).should('be.visible'); } - cy.contains('ui5-message-strip', /created/).should('not.exist'); - cy.get('ui5-button[data-testid="delete"]').click(); if (confirmationEnabled) { @@ -201,7 +199,7 @@ Cypress.Commands.add( .click(); if (deletedVisible) { - cy.contains('ui5-message-strip', /deleted/).should('be.visible'); + cy.contains('ui5-toast', /deleted/).should('be.visible'); } if (clearSearch) {