Hi @craftzdog, I encountered two small bugs when working on a plugin. I will describe both in this post.
Info
- Platform: Ubuntu
- Platform version: 18.04
- App Version: 4.4.1
1. MessageDialog overlay bug
For a plugin I only want to allow the user to dismiss a dialog when explicitly clicking a button and not when clicking on the (darkened) dialog background.
I do this by setting the “onDismiss” function call in the MessageDialog component to return false
by default:
<MessageDialog {...} onDismiss={(caller, buttonIndex) => {
if (buttonIndex == 0) {
doStuff();
return true;
}
return false;
}} />
This works fine but when I click on the darkened background overlay, it disappears (buttonIndex
is -1
in this case). The dialog however is still shown (as it should):
The expected behavior would be: When clicking on the background the overlay and the dialog stay where they are.
2. editingNote save bug
Not sure if this is a bug or if I am doing it wrong but after modifying the editor content via the redux dispatch the note is not saved even when the core:save-note
command is executed.
inkdrop.store.dispatch(actions.editingNote.update({ body: newBody }))
setTimeout(
() => inkdrop.commands.dispatch(document.body, 'core:save-note'),
500
)
The core:save-note
command is executed with a 500ms delay. This is because the store dispatch is an async call and one has to make sure the save command is executed after the store has been updated.
For the actual code, checkout open-in-editor-message-dialog.js
Let me know if you have any questions.
Cheers,
Andreas