-
Notifications
You must be signed in to change notification settings - Fork 0
Added cross-browser fullscreen behaviour #47
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
base: vnext
Are you sure you want to change the base?
Conversation
mddragnev
left a comment
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.
Two more things:
1.

Entering full screen mode there is an additional scrollbar.
- All the checks whether window/document is defined are redundant here because we are using client side code in the entire file. Event if we migrate this project to SSR we should either refactor the whole file or mark it as
'use client'. However, this is something that I can live with so just FYI
| downloadLink: string; | ||
| } | ||
|
|
||
| interface TabItemProps { |
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.
I think having these as interfaces is much more readable than putting them as types of the arguments in the component
| document.exitFullscreen?.() || | ||
| (document as any).webkitExitFullscreen?.(); | ||
|
|
||
| const checkFullscreen = () => |
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.
Two identical functions checkFullScreen.
| return; | ||
| if (typeof window === "undefined" || typeof document === "undefined") return; | ||
|
|
||
| const checkFullscreen = () => |
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.
Why is this a function?
| setActiveView(location.pathname.replace("/home/", "")); | ||
| }, [location]); | ||
|
|
||
| useEffect(() => { |
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.
What I dont like in this useEffect is that it is too complicated. Do you really need to reattach the event listeners for fullscreen handling on each location change? Isn't it better to split up the Effect into two separate so that the event listeners are added only once, and then the tabs logic is changed on location? Also I dont think that we need all this state. There might be some state that can be derived but this is probably not the time for this.
|
|
||
| const onToggleFullscreen = async () => { | ||
| if (typeof document === "undefined") return; | ||
| const onToggleFullscreen = useCallback(async () => { |
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.
Why do you need useCallback here?
| await exitFullscreen(); | ||
| } | ||
|
|
||
| setIsFullscreen(checkFullscreen()); |
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.
Do you need to set it here as well?
You have some event listeners in the effect that should take care of changing the state
| setIsChartsSection(false); | ||
| } | ||
|
|
||
| setActiveView(path); |
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.
There is a usEffect above that does the same thing? Why dont you remove the one above?
Edit: As I am looking at this, couldnt activeView be a derived variable instead of state?
Related to: IgniteUI/angular-grid-examples#147