Skip to content

Commit

Permalink
[TextField] Add the event to the onBlur prop's arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
chloerice committed Jun 15, 2022
1 parent 3564575 commit 8756c99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-ducks-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added support for the `event` argument to the `TextField` `onBlur` prop
10 changes: 5 additions & 5 deletions polaris-react/src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ interface NonMutuallyExclusiveProps {
/** Callback fired when value is changed */
onChange?(value: string, id: string): void;
/** Callback fired when input is focused */
onFocus?: (event?: React.FocusEvent<HTMLElement>) => void;
/** Callback fired when focus is removed */
onBlur?(): void;
onFocus?: (event?: React.FocusEvent) => void;
/** Callback fired when input is blurred */
onBlur?(event: React.FocusEvent): void;
}

export type MutuallyExclusiveSelectionProps =
Expand Down Expand Up @@ -473,11 +473,11 @@ export function TextField({
}
};

const handleOnBlur = () => {
const handleOnBlur = (event: React.FocusEvent) => {
setFocus(false);

if (onBlur) {
onBlur();
onBlur(event);
}
};

Expand Down

0 comments on commit 8756c99

Please sign in to comment.