Skip to content

Commit 5fa2c25

Browse files
authored
[DataGrid] Prevent Safari 26 error in the event handler (#20382)
1 parent e8363cc commit 5fa2c25

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/x-data-grid/src/hooks/utils/useGridApiEventHandler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export function createUseGridApiEventHandler(registryContainer: RegistryContaine
5050

5151
if (!subscription.current && handlerRef.current) {
5252
const enhancedHandler: GridEventListener<E> = (params, event, details) => {
53-
if (!event.defaultMuiPrevented) {
53+
// Check for the existence of the event once more to avoid Safari 26 issue
54+
// https://github.com/mui/mui-x/issues/20159
55+
if (event && !event.defaultMuiPrevented) {
5456
handlerRef.current?.(params, event, details);
5557
}
5658
};
@@ -82,7 +84,9 @@ export function createUseGridApiEventHandler(registryContainer: RegistryContaine
8284
React.useEffect(() => {
8385
if (!subscription.current && handlerRef.current) {
8486
const enhancedHandler: GridEventListener<E> = (params, event, details) => {
85-
if (!event.defaultMuiPrevented) {
87+
// Check for the existence of the event once more to avoid Safari 26 issue
88+
// https://github.com/mui/mui-x/issues/20159
89+
if (event && !event.defaultMuiPrevented) {
8690
handlerRef.current?.(params, event, details);
8791
}
8892
};

0 commit comments

Comments
 (0)