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

Style of navbar fixed for wikitonary #1251

Closed
wants to merge 2 commits into from
Closed

Style of navbar fixed for wikitonary #1251

wants to merge 2 commits into from

Conversation

bakshiutkarsha
Copy link
Contributor

Fixes #1033

@codecov
Copy link

codecov bot commented Aug 17, 2020

Codecov Report

Merging #1251 into master will decrease coverage by 0.09%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1251      +/-   ##
==========================================
- Coverage   68.80%   68.71%   -0.10%     
==========================================
  Files          25       25              
  Lines        2199     2199              
  Branches      420      420              
==========================================
- Hits         1513     1511       -2     
- Misses        514      515       +1     
- Partials      172      173       +1     
Impacted Files Coverage Δ
src/util/articleRenderers.ts 70.00% <0.00%> (-2.23%) ⬇️

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 bfd2f36...ea41cce. Read the comment docs.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

This need an in detail explanation why we need to insert custom CSS. Why the CSS of the online version is not sufficient?

@bakshiutkarsha
Copy link
Contributor Author

This need an in detail explanation why we need to insert custom CSS. Why the CSS of the online version is not sufficient?

As per the discussion on the issue thread and based on my investigation, it seems that either the event handler for toggling the visibility of the navframe is not getting attached or the custom CSS inserted by mwoffliner is causing problems with the visibility. To fix tthe issues, I tried both the approaches mentioned on the issue thread:

  • Using javascript: I added a custom JS script to be bundled and loaded in the article page to remove client-js class from body and add the client-nojs class to it. This solution doesn't seem to fix the visibility issue.

  • So finally, I had to retort to adding custom CSS that overrides the existing CSS for the NavFrame. This fixes the issue and the translations are visible as the custom CSS is marked important and would always override conflicting CSS property for this CSS class. The chances of it breaking something else is very low as the CSS is applied on just 1 property of 1 class.

@kelson42
Copy link
Collaborator

@bakshiutkarsha We should retrieve any css/js from the online version. If not we need to understand exactly why. This explanation is missing here... you fix a problem which is not even understodd priperly. This should be avoided.

@bakshiutkarsha
Copy link
Contributor Author

@bakshiutkarsha We should retrieve any css/js from the online version. If not we need to understand exactly why. This explanation is missing here... you fix a problem which is not even understodd priperly. This should be avoided.

#1033 (comment)
@kelson42 Now, I carefully scrutinized all the comments by @Jaifroid on this ticket and this last comment helped me to resolve it. His previous comments have explained exactly the question of why is it happening and how to resolve it. I made the same fix suggested by him. Let me know if you think this fix is not proper, I will try to dig deeper.

@Jaifroid
Copy link
Collaborator

I'd be happy to test / troubleshoot the implementation here, but it may take a few days.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

No, like I said many times, I don’t want dependence to the wiki content in mwoffliner code.

@@ -112,7 +112,7 @@ const renderMCSArticle = (json: any, dump: Dump, articleId: string, articleDetai
const firstTocLevel = json.remaining.sections[0].toclevel;
json.remaining.sections
.forEach((oneSection: any, i: number) => {
if (oneSection.toclevel === firstTocLevel) {
if (oneSection.toclevel === firstTocLevel || oneSection.text.indexOf('class="NavFrame"')) {
Copy link
Collaborator

@Jaifroid Jaifroid Aug 29, 2020

Choose a reason for hiding this comment

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

@bakshiutkarsha I'm not commenting on the general idea here, but only on your use of indexOf. The indexOf method returns -1 if the string you are searching does not contain the search string, not 0. Therefore, unless I've misunderstood what you're trying to do, I think you need:

~oneSection.text.indexOf('class="NavFrame"')

Note the tilde at the start. This converts -1 to 0, and 0 to -1, etc. Therefore, if the text appears at position 0, the tilde converts 0 to -1 and the test will pass. But if indexOf returns -1 (not found), the tilde converts it to 0, and the test fails.

Copy link
Collaborator

Choose a reason for hiding this comment

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

PS It would probably be better to use the classList.contains() method for this test. It is supported on IE10+. See https://dev.caniuse.com/classlist .

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, your test would fail if an editor had written class='NavFrame' with single quotes or class="dark NavFrame", hence why using classList.contains() is safer.

@kelson42
Copy link
Collaborator

kelson42 commented Sep 1, 2020

@bakshiutkarsha Any news here? If our section mgmt code css+js is not able to make the difference between our section code and the content code, then we need to specify our DOM nodes properly, like for example by putting class="_mwoffliner"?

@stale
Copy link

stale bot commented Sep 9, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label Sep 9, 2020
@kelson42 kelson42 closed this Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wiktionary translations can't be shown
3 participants