-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Only select TextTrackMenuItem if unselected #4920
Merged
gkatsev
merged 10 commits into
videojs:master
from
alex-barstow:only-update-tt-selected-state-if-changed
Feb 9, 2018
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b95387c
wip
alex-barstow e460dd0
more experimentation, logging
alex-barstow 7250409
remove logging, clean upcomments
alex-barstow 4fcf5eb
remove event arg used for testing
alex-barstow abf8bf4
add comment
alex-barstow a626b17
set value of isSelected_ in selected() method
alex-barstow e5eb6cd
better comment
alex-barstow 8995ad9
remove empty handleTracksChange method from caption settings menu item
alex-barstow 52277b4
simplify conditional, rename variable
alex-barstow 343510a
add default value for isSelected_
alex-barstow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,9 @@ class MenuItem extends ClickableComponent { | |
super(player, options); | ||
|
||
this.selectable = options.selectable; | ||
this.isSelected_ = options.selected; | ||
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. looks like we need a default value here. |
||
|
||
this.selected(options.selected); | ||
this.selected(this.isSelected_); | ||
|
||
if (this.selectable) { | ||
// TODO: May need to be either menuitemcheckbox or menuitemradio, | ||
|
@@ -93,11 +94,13 @@ class MenuItem extends ClickableComponent { | |
// aria-checked isn't fully supported by browsers/screen readers, | ||
// so indicate selected state to screen reader in the control text. | ||
this.controlText(', selected'); | ||
this.isSelected_ = true; | ||
} else { | ||
this.removeClass('vjs-selected'); | ||
this.el_.setAttribute('aria-checked', 'false'); | ||
// Indicate un-selected state to screen reader | ||
this.controlText(''); | ||
this.isSelected_ = false; | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this and and in text-text-menu-item, the two ifs can be collapsed into
shouldBeSelected && !this.iSelected_
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 I understand correctly, that would create scenarios where
shouldBeSelected
is true,isSelected_
is true, yet we would deselect the menu item. In that case where both those values are true, we should just do nothing.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.
Ah, right, makes sense. What about moving the check into the
this.selected
method?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.
Yeah I considered it. It was kind of a toss up, but in the end I decided I found it clearer to conditionally call
.selected()
rather than always call it and conditionally have it do nothing, if that makes sense. I don't have a particularly strong preference, so if you find it clearer to have the logic in the selected method itself I'm happy to move 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.
Nah, don't really have much preference one way or the other. @videojs/core-committers do you have any thoughts?
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.
Since we're making this change, it seems unnecessary to allow redundant
selected(false)
calls as well. How aboutshouldBeSelected && shouldBeSelected !== this.isSelected_)
for the first if and!shouldBeSelected && shouldBeSelected !== this.isSelected_
for the second?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.
That sounds good to me
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.
Or even this: