Skip to content

Add a table option for IME input #258

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

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const MRT_EditCellTextInput = <TData extends MRT_RowData>({

const handleEnterKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
textInputProps.onKeyDown?.(event);
if (event.key === 'Enter') {
if (event.key === 'Enter' && table.options.enableIMEMode !== true) {
editInputRefs.current[cell.id]?.blur();
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/mantine-react-table/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
enableFullScreenToggle?: boolean;
enableGlobalFilterModes?: boolean;
enableGlobalFilterRankedResults?: boolean;
enableIMEMode?: boolean;
enablePagination?: boolean;
enableRowActions?: boolean;
enableRowDragging?: boolean;
Expand Down
48 changes: 48 additions & 0 deletions packages/mantine-react-table/stories/features/Editing.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,54 @@ export const EditingEnabledEditModeCustom = () => {
);
};

export const EditingEnabledEditModeWithIMEInput = () => {
const [tableData, setTableData] = useState(data);
const handleSaveRow: MRT_TableOptions<Person>['onEditingRowSave'] = ({
exitEditingMode,
row,
values,
}) => {
tableData[row.index] = values;
setTableData([...tableData]);
exitEditingMode();
};

const columns = [
{
accessorKey: 'firstName',
header: 'First Name',
},
{
accessorKey: 'lastName',
header: 'Last Name',
},
{
accessorKey: 'address',
header: 'Address',
},
{
accessorKey: 'state',
header: 'State',
},
{
accessorKey: 'phoneNumber',
enableEditing: false,
header: 'Phone Number',
},
];

return (
<MantineReactTable
columns={columns}
data={tableData}
enableEditing
enableIMEMode
enableRowNumbers
onEditingRowSave={handleSaveRow}
/>
);
};

export const CustomEditModal = () => {
const [tableData, setTableData] = useState(data);

Expand Down