-
Notifications
You must be signed in to change notification settings - Fork 19
Akmal / feat: add RTL support to VideoPlayer component and its controls #405
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
Conversation
Dependency Reviewβ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
|
Claude finished @akmal-deriv's task ββ View job Code Review CompleteI've reviewed the RTL support implementation for the VideoPlayer component. Here's my comprehensive analysis: SummaryThe PR successfully adds RTL (right-to-left) support to the VideoPlayer component using a smart approach: forcing LTR direction on the video player itself while applying transform mirroring to the progress bar. This is a common pattern for video players in RTL interfaces. Priority Breakdown:
Detailed Reviewβ What Works Well
Issues & Recommendationsπ‘ Medium Priority1. Incomplete Transform Application (video-player.scss:6) Location: Issue: The wrapper has &__wrapper {
position: relative;
direction: ltr !important;
}The comment on line 81 states: // Transform is now handled dynamically in the component based on RTL stateHowever, I don't see any dynamic transform being applied to the wrapper itself, only to the progress bar. Recommendation:
π’ Low Priority - Code Quality2. Prop Default Value Redundancy (video-controls.tsx:53) Location: Issue: The is_rtl = false,But it's also marked as optional in the type definition (line 24). This is technically fine but creates redundancy. Recommendation: Consider whether this default should remain or if it should always be explicitly passed from the parent. 3. Test Coverage for scaleX Transform Location: Issue: The test "should render progress bar correctly in RTL mode without reversing direction" checks that elements exist but doesn't verify the actual Current test: it('should render progress bar correctly in RTL mode without reversing direction', () => {
(useIsRtl as jest.Mock).mockReturnValue(true);
render(<VideoPlayer {...mocked_props} />);
// ... checks for element existence only
});Recommendation: Add assertion to verify the transform style: const progress_bar = screen.getByTestId('dt_progress_bar');
expect(progress_bar).toHaveStyle({ transform: 'scaleX(-1)' });4. Error Handling Feedback Location: Issue: The try {
return useIsRtl();
} catch (_error) {
return false;
}Recommendation: Consider logging the error in development mode to help with debugging: try {
return useIsRtl();
} catch (error) {
if (process.env.NODE_ENV === 'development') {
console.warn('useIsRtl hook failed:', error);
}
return false;
}Security, Performance & Best Practicesβ Security: No security concerns identified. No XSS risks, no sensitive data exposure. β
Performance: No performance issues. The β React Best Practices: Code follows React/TypeScript conventions properly. β Type Safety: All new props are properly typed. Testing RecommendationsThe existing test coverage is good but could be enhanced:
Verdictβ Approved for merge with minor improvements recommended. The implementation is solid and follows the correct pattern for RTL video player support. The identified issues are all low-to-medium priority and don't block the PR from being merged. They can be addressed in follow-up improvements if desired. |
Deploying derivatives-trader with Β
|
| Latest commit: |
a2ddc05
|
| Status: | Β β Β Deploy successful! |
| Preview URL: | https://e32ce420.derivatives-trader.pages.dev |
| Branch Preview URL: | https://b-video-player-ltr.derivatives-trader.pages.dev |
packages/components/src/components/video-player/video-player.scss
Outdated
Show resolved
Hide resolved
π€ AI Code Analysis Resultsπ Manual Codingβ¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬ 0% 0 of 1,446 characters (0%) in newly added lines are AI-generated π Analysis Summary
π Per-File Breakdown (New Lines Only)
π This PR contains traditional hand-written code. π Raw Data (for dashboard){
"timestamp": "2025-11-05T06:30:43.331Z",
"repository": "deriv-com/derivatives-trader",
"branch": "unknown",
"author": "unknown",
"summary": {
"totalCharacters": 1446,
"aiCharacters": 0,
"percentage": 0
},
"files": [
{
"name": "packages/components/src/components/video-player/__tests__/video-player.spec.tsx",
"totalCharacters": 858,
"aiCharacters": 0,
"percentage": 0,
"status": "modified",
"hasAddedContent": true,
"addedContent": "\nimport { useIsRtl } from '@deriv/api';\nimport VideoPlayer from '../video-player';\n\njest.mock('@deriv/api', () => ({\n useIsRtl: jest.fn(() => false),\n}));\n it('should render progress bar correctly in RTL mode without reversing direction', () => {\n (useIsRtl as jest.Mock).mockReturnValue(true);\n\n render(<VideoPlayer {...mocked_props} />);\n const video = screen.getByTestId(video_data_testid);\n fireEvent.loadedData(video);\n\n expect(screen.getByTestId(player_..."
},
{
"name": "packages/components/src/components/video-player/video-controls.tsx",
"totalCharacters": 218,
"aiCharacters": 0,
"percentage": 0,
"status": "modified",
"hasAddedContent": true,
"addedContent": "import clsx from 'clsx';\n\n\nimport Text from '../text';\n\nimport VolumeControl from './volume-control';\n is_rtl?: boolean;\n is_rtl = false,\n style={{ transform: is_rtl ? 'scaleX(-1)' : 'scaleX(1)' }}"
},
{
"name": "packages/components/src/components/video-player/video-player.scss",
"totalCharacters": 179,
"aiCharacters": 0,
"percentage": 0,
"status": "modified",
"hasAddedContent": true,
"addedContent": " direction: ltr;\n direction: ltr;\n direction: ltr;\n direction: ltr;\n direction: ltr;\n direction: ltr;"
},
{
"name": "packages/components/src/components/video-player/video-player.tsx",
"totalCharacters": 191,
"aiCharacters": 0,
"percentage": 0,
"status": "modified",
"hasAddedContent": true,
"addedContent": "import throttle from 'lodash.throttle';\nimport { useDebounceCallback } from 'usehooks-ts';\n\n\nimport VideoOverlay from './video-overlay';\n } catch (_error) {\n is_rtl={is_rtl}"
}
]
}π Analysis powered by ShiftAI β’ Analyzes only PR changes, not entire files |
|
Claude finished @akmal-deriv's task ββ View job Code Review Complete βI've reviewed the RTL support implementation for the VideoPlayer component. Here's my comprehensive analysis: SummaryThis PR successfully adds RTL (right-to-left) support to the VideoPlayer component. The implementation uses a smart approach: forcing LTR direction on the video player controls while applying CSS transform mirroring ( Priority Breakdown:
Detailed Reviewβ What Works Well
Issues & Recommendationsπ‘ Medium Priority1. Critical Logic Fix: Removed Width Calculation Logic Location: Issue: The commit removed this important line from if (is_rtl) new_width = full_width - new_width;However, this removal appears to be intentional to match the new CSS-based transform approach. But I'm concerned this might cause incorrect behavior:
Recommendation:
2. Incomplete Test Coverage Location: Issue: The new RTL test only checks that elements exist, but doesn't verify:
Current test: it('should render progress bar correctly in RTL mode without reversing direction', () => {
(useIsRtl as jest.Mock).mockReturnValue(true);
render(<VideoPlayer {...mocked_props} />);
// ... only checks element existence
});Recommendation: Enhance the test: it('should render progress bar correctly in RTL mode without reversing direction', () => {
(useIsRtl as jest.Mock).mockReturnValue(true);
render(<VideoPlayer {...mocked_props} />);
const video = screen.getByTestId(video_data_testid);
fireEvent.loadedData(video);
const progress_bar = screen.getByTestId('dt_progress_bar');
expect(progress_bar).toHaveStyle({ transform: 'scaleX(-1)' });
// Test interaction: click progress bar in RTL mode
await userEvent.click(progress_bar);
// Add assertions to verify correct seek position
});π’ Low Priority - Code Quality3. Misleading SCSS Comment Location: Issue: The comment states: // Transform is now handled dynamically in the component based on RTL stateBut this appears above the Recommendation:
4. Excessive Location: Issue: The PR adds
This seems excessive. If Recommendation:
5. Prop Default Value Redundancy Location: Issue: The
Recommendation: This is fine but consider the pattern: if all optional props use default values in destructuring, this is consistent. If not, consider standardizing the approach. 6. Import Organization Changes Location: Multiple files Issue: The PR includes import reordering changes that aren't related to the RTL feature:
Recommendation: While import organization is good, consider keeping refactoring separate from feature PRs to make reviews easier. For this PR, it's acceptable but something to keep in mind. Security, Performance & Best Practicesβ Security: No security concerns identified. No XSS risks, no sensitive data exposure. β
Performance: No performance issues. The β
React Best Practices: Code follows React/TypeScript conventions properly. Proper use of memoization with β Type Safety: All new props are properly typed with TypeScript.
Testing RecommendationsRequired:
Nice to Have:
VerdictThe implementation follows the correct pattern for RTL video player support. However, there's a critical concern about whether progress bar interactions work correctly in RTL mode after removing the width calculation adjustment. Before merging:
Issues #3-6 are minor and don't block merging, but Issue #1 and #2 should be addressed to ensure the feature works correctly. |
|
Claude finished @akmal-deriv's task ββ View job Code Review Complete βI've thoroughly reviewed the RTL support implementation for the VideoPlayer component. Here's my comprehensive analysis: SummaryThis PR adds RTL (right-to-left) support to the VideoPlayer component using a CSS-based approach: forcing LTR direction on video controls while applying Priority Breakdown:
Detailed Reviewβ What Works Well
Issues & Recommendationsπ΄ High Priority - Critical1. Removed Width Calculation for RTL (video-player.tsx:111) Issue: This line was removed in the changes: if (is_rtl) new_width = full_width - new_width;Analysis:
Expected Behavior:
Recommendation:
The CSS transform creates a visual mirror but doesn't fix the interaction logic. You need both the visual transform AND the coordinate adjustment. Suggested fix: let new_width =
((client_X - shift_X - (progress_bar?.getBoundingClientRect().left ?? 0)) /
(progress_bar?.getBoundingClientRect().width ?? 0)) *
full_width;
if (is_rtl) new_width = full_width - new_width; // Restore this line
if (new_width >= full_width) new_width = full_width;
if (new_width <= 0) new_width = 0;π‘ Medium Priority2. Insufficient Test Coverage (video-player.spec.tsx:140-156) Issue: The RTL test only verifies elements exist, not the actual behavior: it('should render progress bar correctly in RTL mode without reversing direction', () => {
(useIsRtl as jest.Mock).mockReturnValue(true);
render(<VideoPlayer {...mocked_props} />);
// ... only checks element existence
});Missing test coverage:
Recommendation: it('should render progress bar correctly in RTL mode without reversing direction', () => {
(useIsRtl as jest.Mock).mockReturnValue(true);
render(<VideoPlayer {...mocked_props} />);
const video = screen.getByTestId(video_data_testid);
fireEvent.loadedData(video);
const progress_bar = screen.getByTestId('dt_progress_bar');
// Verify the transform is applied
expect(progress_bar).toHaveStyle({ transform: 'scaleX(-1)' });
// Test interaction (if Issue #1 is fixed)
await userEvent.click(progress_bar);
// Add assertions for seek position
});π’ Low Priority - Code Quality3. Excessive Issue: Added
Analysis: If Recommendation:
4. Import Reordering (Multiple Files) Issue: Includes unrelated import reorganization:
Recommendation: While import organization is good, keep refactoring separate from feature PRs for easier reviews. Acceptable here, but keep in mind for future PRs. Security, Performance & Best Practicesβ Security: No security concerns. No XSS risks, no sensitive data exposure. β
Performance: No issues. β
React/TypeScript Best Practices: Code follows conventions properly. Good use of β Type Safety: All new props properly typed. Testing RecommendationsRequired Before Merge:
VerdictThe implementation follows the correct pattern, but there's a critical concern about progress bar interaction in RTL mode. Before merging:
The CSS transform mirrors the visual appearance but doesn't automatically adjust mouse coordinates. You likely need both the visual transform AND the coordinate adjustment for correct behavior. |
Description
Related Issue: Fixes #(issue)
Type of Change
Testing
Screenshots
(Add screenshots if UI changes)
Before:
After: