-
Notifications
You must be signed in to change notification settings - Fork 147
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(blade): Trigger native select events in dropdown/ file upload / Date picker [FC-3151] #2408
Merged
Merged
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
03cb1bb
chore: trigger native events
tewarig 48182f7
chore: trigger native events
tewarig 0c355c1
fix: fireNativeEvents in case of dropdown
tewarig 90d7063
chore: remove extra code
tewarig 7f537a3
chore: change value of fireNative events to unknown
tewarig d75fa17
chore: remove fireNativeEvent from autocompelte
tewarig 5d16744
chore: remove add fireNative event on remove , dissmiss
tewarig 45b43f9
chore: remove logs
tewarig b683440
chore: code clean up
tewarig f66ef5f
chore: minor change
tewarig 6440afd
chore: minor changes
tewarig 497aff1
chore: fix type
tewarig bf6083f
chore: fire native event is not supported on react-native
tewarig 4a5abdc
chore: change fire native event
tewarig 2a8975f
chore: review change useFireNativeEvent
tewarig c4887f6
feat: added fireNativeEvent test
tewarig 9295b8d
chore: test for fireNativeEvent react native
tewarig 92235e5
Merge branch 'master' of https://github.com/razorpay/blade into fix/t…
tewarig 7a6cfa9
chore: update fireNativeEvent error
tewarig f023d4c
chore: add tests in AutoComplete
tewarig 42b8c3d
feat: add test for fire naitve event in DatePicker
tewarig 5e517b3
feat: added test case for FileUpload
tewarig d139e26
chore: sync with main
tewarig 500e30f
fix: failing build
tewarig 2e3b148
chore: update snap
tewarig 277c1b9
chore: add fixes to fireNativeEvent
tewarig a7657a4
Merge branch 'master' of https://github.com/razorpay/blade into fix/t…
tewarig d6947b0
chore: change throwBladeError to logger
tewarig f0d49f5
chore: fix errors
tewarig 82104ef
chore: increase timeout
tewarig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/blade/src/utils/fireNativeEvent/fireNativeEvent.web.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Fires native events on a given HTML element reference. | ||
* | ||
* @param ref - A React ref object pointing to an HTML element or null. | ||
* @param eventTypes - An array of event types to be dispatched. Supported event types are 'change' and 'input'. | ||
* | ||
* @remarks | ||
* This function creates and dispatches native events of the specified types on the element referenced by `ref`. | ||
* If `ref` is null, a warning is logged to the console. | ||
* | ||
* @example | ||
* ```typescript | ||
* const inputRef = React.createRef<HTMLInputElement>(); | ||
* fireNativeEvent(inputRef, ['change', 'input']); | ||
* ``` | ||
*/ | ||
|
||
export const fireNativeEvent = ( | ||
ref: React.RefObject<HTMLElement> | null, | ||
eventTypes: Array<'change' | 'input'>, | ||
): void => { | ||
if (ref) { | ||
eventTypes.forEach((eventType) => { | ||
const event = new Event(eventType, { bubbles: true }); | ||
ref.current?.dispatchEvent(event); | ||
}); | ||
} else { | ||
console.warn('ref is not defined'); | ||
} | ||
tewarig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './fireNativeEvent.web'; | ||
tewarig marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the normal DOM inputs if we actually fire both of these or not. I think they do but still confirm once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked for
<input type="file" />
they do fire both change and input .