Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Modal Accessibility and copy paste. #33509

Merged
merged 8 commits into from
May 17, 2024
Merged

Conversation

marks0351
Copy link
Member

@marks0351 marks0351 commented May 16, 2024

workerB

Description

In this Pr we are tackling a few issues.

  • disallow copy pasting modals into other widgets instead always paste them on the main canvas.
  • disable modal header and footer accessibility in edit mode.
  • make sure edit mode based wrappers are not wrapped for skeleton widget.
  • make sure widget name is not shown for skeleton widget.
  • fixed random errors in the withWidgetProps flow
  • removed unwanted invocation of setting highlights.

Fixes #33382
Fixes #32923

or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9125695828
Commit: 05d011b
Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

@marks0351 marks0351 requested a review from a team as a code owner May 16, 2024 05:30
@marks0351 marks0351 requested review from riodeuno and KelvinOm and removed request for a team and riodeuno May 16, 2024 05:30
Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

Walkthrough

The recent updates focus on enhancing modal components with the addition of the excludeFromTabOrder property for improved accessibility control. Changes also address widget rendering and drag-and-drop behavior in the Anvil editor, aiming to enhance user experience and code maintainability.

Changes

Files Change Summary
.../Modal/src/ModalFooter.tsx, .../Modal/src/ModalHeader.tsx, .../Modal/src/types.ts Introduced excludeFromTabOrder property for managing tab order in modal components.
.../AnvilEditorWidgetOnion.tsx, .../AnvilWidgetName/index.tsx Updated logic for widget handling based on SKELETON_WIDGET_TYPE and excluded widget name display for specific types.
.../AnvilDragPreview/AnvilDragPreviewComponent.tsx, .../hooks/useAnvilDnDEvents.ts Enhanced drag preview behavior to stay within the visible area and conditionally reset canvas state on drag end.
.../widgets/withWidgetProps.tsx, .../integrations/sagas/pasteSagas.ts Improved error handling logic in widget rendering and introduced specific handling for pasting modal widgets.

Assessment against linked issues

Objective Addressed Explanation
Prevent pasting modal widget into another modal widget (#33382)
Ensure widgets render without appearing as tiny boxes first (#32923) The changes primarily focus on modal and widget handling improvements, not directly related to initial widget rendering issues.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7a41a8d and 05d011b.
Files selected for processing (1)
  • app/client/packages/design-system/widgets/src/components/Modal/src/ModalHeader.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/widgets/src/components/Modal/src/ModalHeader.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Bug Something isn't working Anvil POD Issue related to Anvil project Anvil team issues related to the new layout system anvil High This issue blocks a user from building or impacts a lot of users Task A simple Todo WDS team labels May 16, 2024
@marks0351 marks0351 added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label May 16, 2024
@github-actions github-actions bot removed the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label May 16, 2024
@marks0351 marks0351 added the ok-to-test Required label for CI label May 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Comment on lines +30 to +51
function* pasteAnvilModalWidgets(
allWidgets: CanvasWidgetsReduxState,
modalWidgetsToPaste: CopiedWidgetData[],
) {
const lastDestinationInfo: PasteDestinationInfo = yield call(
getDestinedParent,
allWidgets,
modalWidgetsToPaste,
allWidgets[MAIN_CONTAINER_WIDGET_ID],
);

// paste into main canvas
const res: PastePayload = yield call(
pasteWidgetsIntoMainCanvas,
allWidgets,
modalWidgetsToPaste,
lastDestinationInfo,
{},
{},
);
return res;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling to pasteAnvilModalWidgets.

To ensure robustness, consider adding a try-catch block to handle potential errors during the paste operation.

+ try {
  const lastDestinationInfo: PasteDestinationInfo = yield call(
    getDestinedParent,
    allWidgets,
    modalWidgetsToPaste,
    allWidgets[MAIN_CONTAINER_WIDGET_ID],
  );

  // paste into main canvas
  const res: PastePayload = yield call(
    pasteWidgetsIntoMainCanvas,
    allWidgets,
    modalWidgetsToPaste,
    lastDestinationInfo,
    {},
    {},
  );
  return res;
+ } catch (error) {
+   // Handle error appropriately
+   console.error("Error pasting modal widgets:", error);
+   return null;
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
function* pasteAnvilModalWidgets(
allWidgets: CanvasWidgetsReduxState,
modalWidgetsToPaste: CopiedWidgetData[],
) {
const lastDestinationInfo: PasteDestinationInfo = yield call(
getDestinedParent,
allWidgets,
modalWidgetsToPaste,
allWidgets[MAIN_CONTAINER_WIDGET_ID],
);
// paste into main canvas
const res: PastePayload = yield call(
pasteWidgetsIntoMainCanvas,
allWidgets,
modalWidgetsToPaste,
lastDestinationInfo,
{},
{},
);
return res;
}
function* pasteAnvilModalWidgets(
allWidgets: CanvasWidgetsReduxState,
modalWidgetsToPaste: CopiedWidgetData[],
) {
try {
const lastDestinationInfo: PasteDestinationInfo = yield call(
getDestinedParent,
allWidgets,
modalWidgetsToPaste,
allWidgets[MAIN_CONTAINER_WIDGET_ID],
);
// paste into main canvas
const res: PastePayload = yield call(
pasteWidgetsIntoMainCanvas,
allWidgets,
modalWidgetsToPaste,
lastDestinationInfo,
{},
{},
);
return res;
} catch (error) {
// Handle error appropriately
console.error("Error pasting modal widgets:", error);
return null;
}
}

Comment on lines +121 to +131
if (modalWidgets.length > 0) {
// paste into main canvas
const res: PastePayload = yield call(
pasteAnvilModalWidgets,
allWidgets,
modalWidgets,
);
allWidgets = res.widgets;
widgetIdMap = { ...widgetIdMap, ...res.widgetIdMap };
reverseWidgetIdMap = { ...reverseWidgetIdMap, ...res.reverseWidgetIdMap };
}
Copy link
Contributor

@coderabbitai coderabbitai bot May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling to the modal widget paste operation.

To ensure robustness, consider adding a try-catch block to handle potential errors during the modal widget paste operation.

+ try {
  if (modalWidgets.length > 0) {
    // paste into main canvas
    const res: PastePayload = yield call(
      pasteAnvilModalWidgets,
      allWidgets,
      modalWidgets,
    );
    allWidgets = res.widgets;
    widgetIdMap = { ...widgetIdMap, ...res.widgetIdMap };
    reverseWidgetIdMap = { ...reverseWidgetIdMap, ...res.reverseWidgetIdMap };
  }
+ } catch (error) {
+   // Handle error appropriately
+   console.error("Error pasting modal widgets:", error);
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (modalWidgets.length > 0) {
// paste into main canvas
const res: PastePayload = yield call(
pasteAnvilModalWidgets,
allWidgets,
modalWidgets,
);
allWidgets = res.widgets;
widgetIdMap = { ...widgetIdMap, ...res.widgetIdMap };
reverseWidgetIdMap = { ...reverseWidgetIdMap, ...res.reverseWidgetIdMap };
}
try {
if (modalWidgets.length > 0) {
// paste into main canvas
const res: PastePayload = yield call(
pasteAnvilModalWidgets,
allWidgets,
modalWidgets,
);
allWidgets = res.widgets;
widgetIdMap = { ...widgetIdMap, ...res.widgetIdMap };
reverseWidgetIdMap = { ...reverseWidgetIdMap, ...res.reverseWidgetIdMap };
}
} catch (error) {
// Handle error appropriately
console.error("Error pasting modal widgets:", error);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a try catch for the scope of pasteWidgetSagas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon reviewing the pasteWidgetSagas function, I can confirm that there is indeed a try-catch block encompassing the entire function. This means that any errors occurring during the modal widget paste operation will already be caught and handled by this existing block.

Therefore, no additional try-catch block is necessary for the modal widget paste operation.

@marks0351, you are correct. The existing try-catch block in the pasteWidgetSagas function already handles errors for the entire scope, including the modal widget paste operation. No further changes are needed for error handling in this context. Thank you for pointing that out!

@@ -6,7 +6,12 @@ import { Button } from "../../Button";
import type { ModalFooterProps } from "./types";

export const ModalFooter = (props: ModalFooterProps) => {
const { closeText = "Close", onSubmit, submitText = "Submit" } = props;
const {
allowInteraction = true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
allowInteraction = true,
excludeFromTabOrder = true,

I think having one name for things that do the same thing is a good idea.

@marks0351
Copy link
Member Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9110388245.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33509.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33509.dp.appsmith.com

@marks0351 marks0351 requested a review from ramsaptami May 16, 2024 11:10
@marks0351 marks0351 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 17, 2024
@marks0351 marks0351 merged commit bb75941 into release May 17, 2024
88 checks passed
@marks0351 marks0351 deleted the modal_deal_breakers branch May 17, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil POD Issue related to Anvil project Anvil team issues related to the new layout system anvil Bug Something isn't working High This issue blocks a user from building or impacts a lot of users ok-to-test Required label for CI Task A simple Todo WDS team
Projects
None yet
3 participants