-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(IpAddress): support ArrowLeft/Right key #6244
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
feat(IpAddress): support ArrowLeft/Right key #6244
Conversation
…ht','Backspace'] expansion operations
|
Thanks for your PR, @momijijin. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's GuideThis PR enhances the IpAddress component by expanding keyboard-driven navigation between IP segment inputs (supporting Space, ArrowLeft, ArrowRight, and refined Backspace behavior) and improves input sanitization by defaulting blank segments to "0" and stripping spaces on update. Class diagram for updated IpAddress component input handlingclassDiagram
class IpAddress {
string Value1
string Value2
string Value3
string Value4
void OnParametersSet()
void UpdateValue()
}
IpAddress : OnParametersSet() sets Value1-4 to "0" if blank/whitespace
IpAddress : UpdateValue() strips all spaces from concatenated IP string
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @momijijin - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js:55` </location>
<code_context>
}
else if (e.key === 'Backspace') {
- if (c.value.length === 0) {
+ if (c.value.length <= 1) {
c.value = "0"
- selectCell(el, index - 1)
+ if (index === 0)
+ e.preventDefault();
+ const prevCell = selectCell(el, index - 1)
+ prevCell.selectionStart = prevCell.value.length
+ prevCell.selectionEnd = prevCell.value.length
}
}
</code_context>
<issue_to_address>
Guard against negative index when selecting previous cell
Add an `if (index > 0)` check before calling `selectCell(el, index - 1)` to prevent out-of-bounds access. Only call `e.preventDefault()` when `index` is 0.
</issue_to_address>
### Comment 2
<location> `src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js:64` </location>
<code_context>
+ prevCell.selectionEnd = prevCell.value.length
}
}
+ // 空格或右箭头(光标一定要在内容最后面)向后换一格
+ else if (current.selectionStart === current.value.length && (e.code === 'Space' || e.code === 'ArrowRight')) {
+ e.preventDefault()
</code_context>
<issue_to_address>
Prevent moving past last cell on ArrowRight or Space
Add a condition to ensure `index + 1` does not exceed `totalSegments - 1` to prevent selecting beyond the last cell.
</issue_to_address>
### Comment 3
<location> `src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js:70` </location>
<code_context>
+ selectCell(el, index + 1)
+ }
+ // 左箭头(光标一定要在内容最前面)向前换一格
+ else if (current.selectionStart === 0 && e.code === 'ArrowLeft') {
+ e.preventDefault()
+ selectCell(el, index - 1)
</code_context>
<issue_to_address>
Prevent moving before first cell on ArrowLeft
Wrap `selectCell(el, index - 1)` with `if (index > 0)` to prevent selecting an invalid cell.
</issue_to_address>
### Comment 4
<location> `src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js:74` </location>
<code_context>
+ e.preventDefault()
+ selectCell(el, index - 1)
+ }
else if (e.key === 'Delete' || e.key === 'Tab' || e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
}
</code_context>
<issue_to_address>
Remove or clarify the redundant empty handler
This branch duplicates existing handlers and does nothing. Please remove it or add a clarifying comment if it's intentional.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6244 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 704 704
Lines 31130 31130
Branches 4402 4402
=========================================
Hits 31130 31130
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@microsoft-github-policy-service agree |
… an extra character when switching to the previous cell.
…onsisting solely of blank spaces.
…earrowleftarrowrightbackspace-expansion-operations
…earrowleftarrowrightbackspace-expansion-operations
Link issues
fixes #6243
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add enhanced keyboard navigation for IP address input fields and improve segment handling by defaulting empty segments to zero and stripping spaces.
New Features:
Bug Fixes: