-
-
Notifications
You must be signed in to change notification settings - Fork 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
Desktop: Focus is lost and notebook disappears (laurent22#10194) #10222
Conversation
|
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA 2 out of 3 committers have signed the CLA. |
|
I have read the CLA Document and I hereby sign the CLA |
|
Hi! Thank you for working on the issue. I made these changes, and yeah, I did not catch that. Calling the Can you check whether your changes affect |
| @@ -744,7 +744,7 @@ const SidebarComponent = (props: Props) => { | |||
|
|
|||
|
|
|||
| if (props.folders.length) { | |||
| const allNotesSelected = props.selectedFolderId === ALL_NOTES_FILTER_ID; | |||
| const allNotesSelected = props.selectedFolderId === null ? true : props.selectedFolderId === ALL_NOTES_FILTER_ID; | |||
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.
Does this mean that "All notes" can have as an ID either ALL_NOTES_FILTER_ID or null? And isn't it possible to ensure it always has ALL_NOTES_FILTER_ID as ID?
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 think it's because of this existing check:
// Sidebar.tsx
const folderItem_click = useCallback((folderId: string) => {
props.dispatch({
type: 'FOLDER_SELECT',
id: folderId ? folderId : null,
});
}, [props.dispatch]);But maybe AliceHincu found some issues or part of the codebase that I am unaware of.
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 understand now. It's because when selecting a SmartFilter, the selectedSmartFilterId is updated, not
theselectedFolderId. And because now the code switches to the SmartFilter folder type later, then the selectedFolderId is null.
I suggest this: props.notesParentType === 'SmartFilter' && props.selectedSmartFilterId === ALL_NOTES_FILTER_ID and create a comment that SmartFilter folder types do not use selectedFolderId but selectedSmartFilterId
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.
Yes that seems like a reasonable solution for now.
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.
@AliceHincu, what is the status of this pull request? Do you think the changes suggested by HahaBill make sense, and if so could you apply them to the PR please?
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 will implement these changes today and I will also check if there are any problems related to the change. I will be back with updates.
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 updated the code. Also, I have noticed that we don't need the call to folderItem_click anymore, the code works fine without it... I also noticed that in tests, when wanting to test the All Notes section, dispatching the action SMART_FILTER_SELECT is enough. I do not know if I am missing something, since I can't see how it can be useful for us anymore. I switched between having the call and not having the call and I don't see any differences.
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.
Basically, I added folderItem_click for the feature where you can have custom ordering for notes in All notes. However, I think that is the out of the scope of this PR. I suggest that I would create another PR for that, let's see what laurent22 has to say.
Anyway, in my opinion the code looks good for now :)
|
By the way does this pull request need to be labelled for GSoC? |
|
Update: Your changes will not work for the // In togglePerFolderSortOrder.ts
// Added another parameter called: folderName
execute: async (_context: CommandContext, folderId?: string, own?: boolean, folderName?: string) => {
PerFolderSortOrderService.set(folderId, own, folderName);
},// Siderbar.tsx
const onAllNotesClick_ = useCallback(() => {
props.dispatch({
type: 'SMART_FILTER_SELECT',
id: ALL_NOTES_FILTER_ID,
});
PerFolderSortOrderService.selectNonFolder('All Notes');
}, [props.dispatch]);
...menuUtils.commandToStatefulMenuItem('togglePerFolderSortOrder', ALL_NOTES_FILTER_ID, undefined, 'All Notes'),// PerFolderSortOrderService.ts
// We will dynamically change the folderName
public static selectNonFolder(folderName: string) {
this.folderName = folderName;
}
public static set(folderId?: string, own?: boolean, folderName?: string) {
let targetId = folderId;
if (folderName !== undefined) {
this.folderName = folderName;
} else {
this.folderName = null;
}
.
.
}
private static getSelectedFolderId(): string {
if (this.folderState.notesParentType === 'Folder') {
return this.folderState.selectedFolderId;
} else if (this.folderState.notesParentType === 'SmartFilter') {
if (this.folderName === 'All Notes') {
return ALL_NOTES_FILTER_ID;
}
} else {
return '';
}
}This works and solves the bug :) Also, this solves the problem of other folders being |
|
My fixes might be out of the scope of the PR. I suggest that we use AliceHincu's implementation to fix the bug as fast as possible since this issue is a high priority and the deadline for the GSoC application is approaching soon. When this PR is merged, I will fix the |
Any comments on the approach I tried in #10220? To me, the approach in this PR looks better... (Edit- by this, I meant Alice's PR) |
Thanks for looking at the issue, too! I had a look and tried to test it, but unfortunately, your changes do not fix the current bug for this issue. |
|
Hi! Sorry for not replying earlier. Yes, this should be labeled for gsoc. |
|
@AliceHincu, ok that's done. Also please remember that the deadline to submit your application is 2 April so if you haven't done so already consider preparing it in parallel. You can also send us a PM so that we can review your project proposal before you submit it as described here: https://discourse.joplinapp.org/t/the-gsoc-application-deadline-is-on-april-2/37107/2 |
|
@AliceHincu, it looks good now but there's a conflict. Could you please fix it and then we can merge? |
|
It looks like 89acde9 has incorrect authorship information (uses an email not associated with the @AliceHincu GitHub account). This seems to be causing the CLA Assistant check to fail. This StackOverflow post may be helpful in changing the author information for 89acde9. |
|
Hi, sorry for not responding earlier, I was sick for a few days. I will take a look at the article today to fix the issue |
|
Thanks for looking into this but this issue has now been fixed in #10370 |
|
Not sure where I shall post this because there are many merged/duplicate issues but I still have something wrong going on related to that. most of it has been fixed, but when I'm in the 'all notes' folder and search for a word, I then go in one of the results of my search and modify the note, and there the note disappears and it jumps to the next note |
This particular issue can be found here: #10236 |
The problem here arises from the fact that "All notes" has as
selectedFolderIdthe value Folder, even though it should have the value SmartFilter. By switching those two lines, the type is correctly set. Before, "All notes" section was treated as a Folder, and for each note it wouldn't show from what notebook it came. After this modification, the UI is correct.When the selected folder id is null, I set the default option to be the "All notes" folder.
Unfortunately I am unable to screen record to showcase this fix, because of some issues with my laptop, I am sorry.