-
Notifications
You must be signed in to change notification settings - Fork 4k
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:onTextChanged action gets triggered on typing numbers after 2 dec… #34355
base: release
Are you sure you want to change the base?
Conversation
WalkthroughThe primary update to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CurrencyInputWidget
User->>CurrencyInputWidget: Types value
CurrencyInputWidget->>CurrencyInputWidget: Calls onValueChange(value)
CurrencyInputWidget->>CurrencyInputWidget: Validate fractional length
CurrencyInputWidget-->>User: Display validated value or error
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
app/client/src/widgets/CurrencyInputWidget/widget/index.tsx (1)
Line range hint
411-411
: Usingsuper
in static methods is flagged as potentially confusing. Consider using the specific class name instead ofsuper
to call superclass methods in static contexts to enhance clarity and maintainability.- super.getPropertyPaneContentConfig() + BaseInputWidget.getPropertyPaneContentConfig()Also applies to: 416-416, 427-427, 434-434
Tools
Biome
[error] 503-503: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/client/src/widgets/CurrencyInputWidget/widget/index.tsx (2 hunks)
Additional context used
Biome
app/client/src/widgets/CurrencyInputWidget/widget/index.tsx
[error] 411-411: Using super in a static context can be confusing. (lint/complexity/noThisInStatic)
super refers to a parent class.
Unsafe fix: Use the class name instead.
[error] 416-416: Using super in a static context can be confusing. (lint/complexity/noThisInStatic)
super refers to a parent class.
Unsafe fix: Use the class name instead.
[error] 427-427: Using super in a static context can be confusing. (lint/complexity/noThisInStatic)
super refers to a parent class.
Unsafe fix: Use the class name instead.
[error] 434-434: Using super in a static context can be confusing. (lint/complexity/noThisInStatic)
super refers to a parent class.
Unsafe fix: Use the class name instead.
[error] 503-503: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Additional comments not posted (1)
app/client/src/widgets/CurrencyInputWidget/widget/index.tsx (1)
501-507
: The changes introduced in theonValueChange
method effectively prevent theonTextChanged
action from being triggered when the fractional part of the input exceeds the specified decimal places. This aligns with the PR's objective. However, consider using optional chaining when accessingthis.props.decimals
to ensure robustness in scenarios whereprops
might be undefined.Verification successful
The
onValueChange
method inapp/client/src/widgets/CurrencyInputWidget/widget/index.tsx
uses the nullish coalescing operator (??
) to handle cases wherethis.props.decimals
might be undefined or null. This ensures that the method defaults to0
in such scenarios, making the code robust.
const decimals = this.props.decimals ?? 0;
This approach effectively handles undefined or null values for
this.props.decimals
, ensuring the method operates correctly without additional optional chaining.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the onValueChange method handles null and undefined values gracefully. # Test: Simulate a call to onValueChange with undefined decimals property. rg --type typescript $'onValueChange(undefined)'Length of output: 84
Script:
#!/bin/bash # Locate the implementation of the onValueChange method. ast-grep --lang typescript --pattern 'onValueChange($_) { $$$ }'Length of output: 514
Script:
#!/bin/bash # Locate the implementation of the onValueChange method with corrected pattern. ast-grep --lang typescript --pattern 'function onValueChange($$) { $$ }'Length of output: 74
Script:
#!/bin/bash # Locate the implementation of the onValueChange method using ripgrep. rg 'onValueChange' --type tsLength of output: 9579
Script:
#!/bin/bash # Extract the implementation of the onValueChange method in CurrencyInputWidget. rg 'onValueChange = ' app/client/src/widgets/CurrencyInputWidget/widget/index.tsx -A 20Length of output: 793
Tools
Biome
[error] 503-503: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
Hello @riodeuno |
Hello @KelvinOm @jsartisan , Could you please review this PR. |
Description:
Summary by CodeRabbit
CurrencyInputWidget
to correctly handle fractional part lengths, ensuring it respects the specified decimal places.PR Type
Bug fix
Description
onTextChanged
action from being triggered when typing numbers after the allowed decimal places in the Currency Input widget.