-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Desktop: Fixes #7834: Merged shorthand variants of spellcheck languages #9983
Conversation
…e bar - Fixed the issue laurent22#7834 - added "spellCheckerMenu.test.ts" to test the changes and the expected behavior: all passed! - added jest.mock in "jest.setup.js" to mock the Menu from @electron/remote. - modified "buildScriptIndexes" to ignore ".test.ts" files so it does not include them in index.ts. That caused some issues with duplicate identifiers and more errors.
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
recheck |
You need to accept the CLA. |
@@ -30,8 +30,9 @@ export const runtime = (): CommandRuntime => { | |||
const s: string[] = []; | |||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied | |||
languages.forEach((language: string) => { | |||
s.push(language.split('-')[0]); |
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.
Obviously it was previously implemented this way for a reason, and you removed that feature.
So what's your reasoning, why do you think it was implemented this way, and is the best fix really to remove it without even a discussion?
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.
Hi, I am sorry that I did not discuss my changes before. I saw in the docs that contributions should be first addressed and discussed in the GitHub issues or Joplin forum. In the future, I will be more aware of that and provide more explicit explanations.
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 added only s.push(language)
and removed s.push(language.split('-')[0]
because to explicitly display the spellcheck languages with different variants like "en-AU, en-GB, en-US"
instead of "en, en, en"
. This is something that tomasz1986 wanted to see and I agree that from the UI/UX perspective, it is better this way.
The changes should not affect SpellCheckerService.ts
and the state: AppState
.
I might have missed something based on your review, let me know!
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.
Here are a few other options:
1. Only show the region code when it prevents duplicate values from being added to s
Another option might be to only include the region code when there are multiple copies of the same language.
For example,
languages = [ 'en-GB', 'en-US' ]
=>s = [ 'en-GB', 'en-US' ]
languages = [ 'en-GB', 'es-MX' ]
=>s = [ 'en', 'es' ]
.
2. Remove duplicates
For example,
languages = [ 'en', 'en', 'en' ]
=>s = [ 'en' ]
This is based on one of the list items in "describe what you expected to happen" in the original issue.
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.
2. Remove duplicates
For example,
languages = [ 'en', 'en', 'en' ]
=>s = [ 'en' ]
This is based on one of the list items in "describe what you expected to happen" in the original issue.
As the author of the original issue, I actually like this approach a lot. It would allow for the language list to take less space, so that more title text could be displayed on the screen, which is precious especially on narrower displays.
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 agree, the second solution is good in terms of usability and reduces clutter. @HahaBill, this is what I was trying to get at: first find out why something was done in a particular way. It was indeed to reduce clutter because putting the language as eg fr-FR or it-IT doesn't help the user.
So the idea would be to keep the clutter to a minimum while solving the original bug report. Actually both solutions 1 or 2 would work but indeed 2 seems better.
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 me, the second solution also looks better than the first one, and everyone seems to lean towards that. The second solution it is! :)
(at sign)laurent22 I see now! That is a really good point and lesson learned. I will keep that in mind.
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 have read the CLA Document and I hereby sign the CLA |
recheck |
@@ -30,8 +30,9 @@ export const runtime = (): CommandRuntime => { | |||
const s: string[] = []; | |||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied | |||
languages.forEach((language: string) => { | |||
s.push(language.split('-')[0]); |
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.
Here are a few other options:
1. Only show the region code when it prevents duplicate values from being added to s
Another option might be to only include the region code when there are multiple copies of the same language.
For example,
languages = [ 'en-GB', 'en-US' ]
=>s = [ 'en-GB', 'en-US' ]
languages = [ 'en-GB', 'es-MX' ]
=>s = [ 'en', 'es' ]
.
2. Remove duplicates
For example,
languages = [ 'en', 'en', 'en' ]
=>s = [ 'en' ]
This is based on one of the list items in "describe what you expected to happen" in the original issue.
@@ -12,7 +12,7 @@ async function processDirectory(dir, indexFilePath = null, typeScriptType = null | |||
|
|||
const tsFiles = glob.sync('{**/*.ts,**/*.tsx}', { | |||
cwd: dir, | |||
}).filter(f => `${dir}/${f}` !== indexFilePath); | |||
}).filter(f => `${dir}/${f}` !== indexFilePath && !f.endsWith('.test.ts')); |
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.
}).filter(f => `${dir}/${f}` !== indexFilePath && !f.endsWith('.test.ts')); | |
}).filter(f => `${dir}/${f}` !== indexFilePath) | |
// Exclude Jest test files to prevent them from being imported | |
// by index.ts. | |
.filter(f => !f.endsWith('.test.ts')); |
(Optional) A brief comment might be helpful here.
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 will do that. Thanks for sharing your implementation!
Because it's possible to click on the spellcheck button and show the full list of languages, I think limiting its size and using |
I think there is an issue with the spellcheck button, as it only shows one language enabled in the menu that pops up on click, even though there are actually four languages enabled. You need to go through the whole "Change language" list to see all of them. |
Yeah, limiting the size and using something like text overflow makes much more sense. Let's talk about that more after this PR and see if other members agree. Another example of using 3 languages where it doesn't look nice: ![]() |
- Test case passed: ['en-GB', 'en-US', 'en-CA', 'es-ES', 'es-MX'] -> 'en, es'
- manually tested locally and the changes work!
I made all the necessary changes. I hope I got everything. |
Here's the issue: #9998 |
That looks good now, thanks everyone! |
@PackElend label me please |
Summary
Introduction from the Joplin Forum: https://discourse.joplinapp.org/t/introducing-hahabill/36075/3
I fixed the issue regarding the multiple variants of the same spellcheck languages showing duplicate values in the title bar. Merged shorthand variants, e.g. [en-US, en-GB, en-AU] -> 'en'
🐛 Fixes: #7834
Testing and Verification Process
1. To ensure the changes are working as expected:
Screen.Recording.2024-02-22.at.23.56.06.mov
2. Unit Testing: showSpellCheckerMenu.test.ts
Notes
I noticed that when I add multiple spellchecker languages, the block expands to the point that it covers the notebook's title.
This is out of the scope of this PR, but I would suggest maybe making the "spellchecker language" block in the title bar horizontally scrollable so that it does not cover the notebook title.
What do you think?
(this suggestion would be out of the scope of this PR, a new issue would be created)
Checklist: