-
Notifications
You must be signed in to change notification settings - Fork 2.8k
perf: Optimization of chat input with line break when pressing enter #2446
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,7 @@ | |
| margin: 0; | ||
| padding: 0; | ||
| } | ||
| [v-cloak] { | ||
| display: none !important; | ||
| } | ||
|
|
||
| html { | ||
| height: 100%; | ||
| box-sizing: border-box; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided CSS code seems fairly well organized. Here is some feedback and potential optimizations: Feedback/Comments:
Here's an optimized version of the code: html {
position: relative; /* Add this for fixed positioning */
min-height: 100%; /* Ensure content fills at least full viewport_height */
box-sizing: border-box;
}
[v-cloak]:not(#app) {
display: none !important;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f6fa; /* Example styling */
}
/* Add other styles here */Changes Made:
|
||
|
|
||
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.
No significant irregularities were found in the provided JavaScript code snippet. The function
insertNewlineAtCursoris implemented correctly to handle newline insertion on a textarea when both Ctrl and Enter keys are pressed, without altering other functionalities.To optimize this function:
textarea.setSelectionRange(), which ensures that the selection moves after the newly inserted newline character. This approach minimizes additional work once the input value has been updated.In summary, there are no immediate issues with the current code and it functions as intended for its purpose. However, using
nextTick()can introduce slight delays depending on browser performance but would not affect functionality significantly. For efficiency, the selection range should be handled directly post-insertion to avoid visual flickering or incorrect selections.