-
Notifications
You must be signed in to change notification settings - Fork 0
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: tableEl undefined #243
Conversation
WalkthroughThe pull request introduces modifications to the Possibly related PRs
🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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 (2)
src/components/DataTable/index.vue (2)
1165-1167
: LGTM: Added null check for tableEl reference.The null check is correctly implemented. However, since this check is identical to the one in
resizeLine
, consider extracting a helper function to reduce duplication.+const isTableElAvailable = () => { + if (!table.value) { + return false; + } + return true; +}; + const resizeLine = () => { if (!options.value.resize) { return; } const tableEl = table.value; - if (!tableEl) { + if (!isTableElAvailable()) { return; } // ... rest of the function }; const createResizableTable = () => { if (!options.value.resize || horizontalScroll.value) { return; } const tableEl = table.value; - if (!tableEl) { + if (!isTableElAvailable()) { return; } // ... rest of the function };
Line range hint
1136-1167
: Consider extracting resizing logic to a composable.The table resizing functionality is complex enough to warrant its own composable. This would:
- Improve code organization
- Make the resizing feature reusable across other components
- Make the main component more focused on table rendering
- Make testing easier
Example structure:
// useTableResize.ts export function useTableResize(options: { table: Ref<HTMLElement | undefined>, minColSize: number, onResize?: (sizes: string[]) => void }) { // ... resizing logic return { resizeLine, createResizableTable, // ... other resize-related functions } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/components/DataTable/index.vue
(2 hunks)
🔇 Additional comments (1)
src/components/DataTable/index.vue (1)
1136-1138
: LGTM: Added null check for tableEl reference.
The addition of this null check prevents potential runtime errors when the table element is not yet available in the DOM.
No description provided.