Skip to content
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

Make legend toggle work in IE11 #2741

Merged
merged 3 commits into from
Jan 29, 2020
Merged

Make legend toggle work in IE11 #2741

merged 3 commits into from
Jan 29, 2020

Conversation

GDFaber
Copy link
Contributor

@GDFaber GDFaber commented Jan 16, 2020

  • Replaced display: initial by display: block in Chart.prototype.show() to stop hidden data items from disappearing in IE11 when they should be shown again (as described in IE 11 legend toggle #2528).
  • Built and tested the changes locally and run tests according to contributing guide.
  • Did not add new tests; if I should do that here, please give me a pointer on how it is done in this case.

@GDFaber GDFaber mentioned this pull request Jan 16, 2020
@codecov-io
Copy link

codecov-io commented Jan 16, 2020

Codecov Report

Merging #2741 into master will decrease coverage by 0.02%.
The diff coverage is 73.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2741      +/-   ##
==========================================
- Coverage   82.85%   82.82%   -0.03%     
==========================================
  Files          60       60              
  Lines        4776     4791      +15     
==========================================
+ Hits         3957     3968      +11     
- Misses        819      823       +4
Impacted Files Coverage Δ
src/api.show.js 88.88% <ø> (ø) ⬆️
src/util.js 92.42% <73.33%> (-5.62%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f35319...90087c7. Read the comment docs.

@kt3k
Copy link
Member

kt3k commented Jan 26, 2020

@GDFaber Thank you for looking into this. The change looks almost good, but we'd like to minimize the effect of change. So can you add the conditional like the below instead of just changing to 'block'?

isIE ? 'block' : 'initial'

@GDFaber
Copy link
Contributor Author

GDFaber commented Jan 26, 2020

Hi @kt3k,

sure, I'll add IE detection as stated above. I have a question about that:

I found a check for IE9 in clip.js/ChartInternal.prototype.getClipPath() as well. Should I add a detection function to util.js (as a part of this PR) and let getClipPath() use it (this would be a new PR then)? or is it ok to just check locally and leave clip.js as it is?

@kt3k
Copy link
Member

kt3k commented Jan 26, 2020

Should I add a detection function to util.js (as a part of this PR) and let getClipPath() use it (this would be a new PR then)?

That sounds good to me.

@GDFaber
Copy link
Contributor Author

GDFaber commented Jan 27, 2020

  • Added functions for IE detection in utils.js
  • Added basic unit tests for the IE detection functions

src/util.js Outdated
*/
export var getIEVersion = function() {
// https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie
const agent = window.navigator.userAgent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about taking agent as function paramter? If we do so, we can write the tests like the below:

expect(getIEVersion('Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko ')).toBe(11)

Copy link
Contributor Author

@GDFaber GDFaber Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's do this. I'm going to modify getIEVersion() to take an optional parameter so usage is kept simple and it can be tested as well.

@@ -10,7 +11,7 @@ Chart.prototype.show = function (targetIds, options) {
targets = $$.svg.selectAll($$.selectorTargets(targetIds));

targets.transition()
.style('display', 'initial', 'important')
.style('display', isIE() ? 'block' : 'initial', 'important')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GDFaber LGTM. Thank you for the contribution!

@kt3k kt3k merged commit 4c30026 into c3js:master Jan 29, 2020
@GDFaber GDFaber deleted the bug/make_legend_toggle_work_in_ie11 branch January 29, 2020 06:52
@GDFaber GDFaber restored the bug/make_legend_toggle_work_in_ie11 branch January 29, 2020 06:52
@GDFaber GDFaber deleted the bug/make_legend_toggle_work_in_ie11 branch January 29, 2020 06:52
@GDFaber GDFaber restored the bug/make_legend_toggle_work_in_ie11 branch January 29, 2020 06:52
@GDFaber GDFaber deleted the bug/make_legend_toggle_work_in_ie11 branch January 29, 2020 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants