Skip to content

Commit

Permalink
Submit form on Enter press (#5419)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate committed Oct 24, 2024
1 parent 9651a5b commit e0b67b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion clients/admin-ui/cypress/e2e/datamap-report.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ describe("Data map report table", () => {
cy.getByTestId("rename-columns-reset-btn").click({ force: true });
cy.getByTestId("column-data_use").should("contain.text", "Data use");
});
it("should support pressing the Enter key to apply renamed columns", () => {
cy.getByTestId("more-menu").click();
cy.getByTestId("rename-columns-btn").click();
cy.getByTestId("column-data_use-input").type("Custom Title{enter}");
cy.getByTestId("column-data_use").should(
"contain.text",
"Custom Title",
);
});
});
});

Expand Down Expand Up @@ -351,7 +360,6 @@ describe("Data map report table", () => {
}).as("getEmptyCustomReports");
cy.getByTestId("custom-reports-trigger").click();
cy.getByTestId("custom-reports-popover").should("be.visible");
cy.wait("@getEmptyCustomReports");
cy.getByTestId("custom-reports-empty-state").should("be.visible");
});
it("should list the available reports in the popover", () => {
Expand Down
4 changes: 3 additions & 1 deletion clients/admin-ui/src/features/common/table/v2/cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
useToast,
WarningIcon,
} from "fidesui";
import { useField } from "formik";
import { useField, useFormikContext } from "formik";
import { ReactNode, useEffect, useMemo, useState } from "react";

import { getErrorMessage, isErrorResult } from "~/features/common/helpers";
Expand Down Expand Up @@ -333,6 +333,7 @@ export const EditableHeaderCell = <T,>({
}) => {
const headerId = props.column.columnDef.id || "";
const [field] = useField(headerId);
const { submitForm } = useFormikContext();
return isEditing ? (
<Input
{...field}
Expand All @@ -341,6 +342,7 @@ export const EditableHeaderCell = <T,>({
aria-label="Edit column name"
size="small"
data-testid={`column-${headerId}-input`}
onPressEnter={submitForm}
/>
) : (
<DefaultHeaderCell value={value} {...props} />
Expand Down

0 comments on commit e0b67b6

Please sign in to comment.