-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Player-54] refacto modal position #124
base: main
Are you sure you want to change the base?
Conversation
439b5ad
to
189adeb
Compare
189adeb
to
67eacec
Compare
eebd8f3
to
7d02725
Compare
…ace by this.instance.video.srcObject
… for determining toOpen from dispatch to reducer in OVERLAY_OPEN action
67eacec
to
3b43091
Compare
|
||
/** | ||
* Creates modal header element with title and close button | ||
* @param {?string} title - Header title content |
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's preferable ? ?string
or string|null
?
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.
string|null is clearer
* @returns {HTMLElement} Configured header element | ||
*/ | ||
createModalHeader(title) { | ||
const header = document.createElement('div'); |
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 not use a semantic element like header
? Is it out of scope for this PR?
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.
Like you said, it's a semantic element used for SEO purposes. The
tag can help improve code understanding for a main header, but I'm not sure it's useful for the readability of a modal. Personally, I prefer usingThere 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.
It's for SEO but also accessibility (used by screen readers for the visually impaired).
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.
Right, but the app isn't ARIA-compliant, so this alone isn't really relevant.
* @returns {HTMLElement} Configured modal element | ||
*/ | ||
createModalElement(classes, width, height) { | ||
const modal = document.createElement('div'); |
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.
<dialog>
wouldn't be relevant?
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.
It could be, since the element comes with a built-in API for opening and closing. However, given the legacy code, I'm not sure it's worth the effort to refactor. For a new project, though, it would definitely be a better choice.
src/plugins/util/OverlayPlugin.js
Outdated
} | ||
|
||
/** | ||
* Initializes drag-and-drop and positioning for the modal |
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.
Is this "drag and drop"? Or just dragging (positioning/moving)?
Is there an action done upon dropping?
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.
It's just dragging, but in my confused mind, 'drag' always comes with 'drop'! >_<
this.video.addEventListener( | ||
'loadedmetadata', | ||
() => { | ||
this.videoWrapper.style.aspectRatio = this.video.videoWidth + '/' + this.video.videoHeight; | ||
}, | ||
{once: true}, | ||
); |
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.
We should check that this doesn't break anything in SiB cc @dpilarsk
]; | ||
} | ||
this.instance.root.focus(); | ||
this.keyboardCallbacks.forEach((item, index, array) => { | ||
array[index].removeListener = this.instance.addListener(this.instance.root, item.event, item.handler); | ||
array[index].removeListener = this.instance.addListener(this.instance.video, item.event, item.handler); |
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 fear this may break everything on Shadow In Browser? cc @dpilarsk
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.
@jparez After discussing a bit with Dimitri, there is no issue with breaking SiB compatibility, we just have to list the breaking changes in the release changelog. (I think changing the html element that listens for the events is probably a breaking change)
if (state.overlay.widgetsOpened.length === 0) { | ||
state.overlay.isOpen = false; | ||
} | ||
if (overlayID) { | ||
state.overlay.widgetsOpened = state.overlay.widgetsOpened.filter((id) => id !== overlayID); | ||
} else { | ||
state.overlay.widgetsOpened = []; | ||
} |
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.
if (state.overlay.widgetsOpened.length === 0) { | |
state.overlay.isOpen = false; | |
} | |
if (overlayID) { | |
state.overlay.widgetsOpened = state.overlay.widgetsOpened.filter((id) => id !== overlayID); | |
} else { | |
state.overlay.widgetsOpened = []; | |
} | |
if (overlayID) { | |
state.overlay.widgetsOpened = state.overlay.widgetsOpened.filter((id) => id !== overlayID); | |
} else { | |
state.overlay.widgetsOpened = []; | |
} | |
if (state.overlay.widgetsOpened.length === 0) { | |
state.overlay.isOpen = false; | |
} |
Shouldn't the widgetsOpened
be cleared before we check if it's empty?
@@ -191,7 +186,7 @@ module.exports = class IOThrottling extends OverlayPlugin { | |||
this.container.appendChild(clearCacheDiv); | |||
|
|||
// Render into document | |||
this.instance.root.appendChild(this.widget); | |||
this.instance.root.appendChild(modal); |
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 don't understand why for some widgets you kept this line while removing it for others but honestly I trust you for it.
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.
for IoThrottling is a mistake :$
@@ -199,7 +199,7 @@ module.exports = class MouseEvents { | |||
|
|||
this.mouseCallbacks.forEach((item, index, array) => { | |||
array[index].removeListener = this.instance.addListener( | |||
this.instance.videoWrapper, | |||
this.instance.video, |
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.
(ShadowInBrowser overrides this function and doesn't call the super function, so no worries here)
const modalWidth = this.widget.offsetWidth || 200; | ||
const modalHeight = this.widget.offsetHeight || 100; |
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.
Maybe these values could be extracted to a CONST at the begining of this file. Similar comment for the +/- 10 values in the next lines of this function
Description
Demo
PLAYER-54-modal-draggable.mp4
Type of change