feat: allow multiple lines in alert component (#36126)
### Description ### Fixes : [#30851](https://github.com/appsmithorg/appsmith/issues/30851) I have raised this pr in-order to allow multiple lines in alert message ### Screenshots ### passing `\n` in the message  ### unable to parse `\n`  ### After issue is resolved  ### Cypress Testing video https://github.com/user-attachments/assets/ec826cef-664f-4392-b81e-9974178e65ec <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new styled component `StyledPre` for enhanced formatting in toast notifications. - Enhanced the Toast component to better render content, improving readability by preserving whitespace and formatting. - Added automated tests for the button widget's alert functionality, ensuring correct display of messages with newline characters. - **Bug Fixes** - Improved the display of alert messages in toast notifications, ensuring they respect original formatting. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
3484a7b74c
commit
a6c109b3ba
|
|
@ -0,0 +1,25 @@
|
|||
import {
|
||||
draggableWidgets,
|
||||
entityExplorer,
|
||||
propPane,
|
||||
agHelper,
|
||||
} from "../../../../../support/Objects/ObjectsCore";
|
||||
|
||||
describe(
|
||||
"Tests for showAlert message with newline characters in the alert message",
|
||||
{ tags: ["@tag.Widget", "@tag.Button"] },
|
||||
() => {
|
||||
before("Login to the app and navigate to the workspace", function () {
|
||||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON);
|
||||
});
|
||||
|
||||
it("Verify showAlert message renders correctly with newline characters", () => {
|
||||
propPane.EnterJSContext("onClick", "showAlert(`sai\n\nprabhu`)");
|
||||
agHelper.ClickButton("Submit");
|
||||
cy.get(".Toastify", { timeout: 1000 }).should(
|
||||
"have.text",
|
||||
"sai\n\nprabhu",
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
@ -63,3 +63,7 @@ export const ToastBody = styled(Text)`
|
|||
export const StyledButton = styled(Button)`
|
||||
align-self: center;
|
||||
`;
|
||||
|
||||
export const StyledPre = styled.pre`
|
||||
font: inherit;
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ import { Slide, toast as toastifyToast } from "react-toastify";
|
|||
import "react-toastify/dist/ReactToastify.min.css";
|
||||
|
||||
import type { ToastProps } from "./Toast.types";
|
||||
import { StyledButton, StyledToast, ToastBody } from "./Toast.styles";
|
||||
import {
|
||||
StyledButton,
|
||||
StyledPre,
|
||||
StyledToast,
|
||||
ToastBody,
|
||||
} from "./Toast.styles";
|
||||
import { getIconByKind } from "../Icon/getIconByKind";
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +45,7 @@ const toast = {
|
|||
|
||||
return toastifyToast(
|
||||
<ToastBody kind="body-m">
|
||||
{content}
|
||||
<StyledPre> {content}</StyledPre>
|
||||
{actionText && (
|
||||
<StyledButton
|
||||
kind="tertiary"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user