News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Message body empty when doing quick edit

Started by ashish101, August 05, 2014, 12:35:08 AM

Previous topic - Next topic

ashish101

Hi

When I try to edit a post using the quick edit button and then if I press ALT+P or ALT+S (keyboard shortcuts for previewing or submitting), it goes to modify post page with blank message textarea and an error saying "The message body was left empty."

Is it a known issue? I tried searching the forum and tried Googling but couldn't find a solution.

PS: It's probably a bug as it's happening here as well.

Mstcool

Why don't you just click preview or submit? :p

ashish101

Quote from: Mstcool on August 05, 2014, 12:46:12 AM
Why don't you just click preview or submit? :p
There's no preview button when doing quick edit.

kat

Is this happening with the SMF default theme? All themes? A custom theme?

Illori

the keyboard shortcuts do not work with the quick edit, they work with the quick reply that is at the bottom of the page, and is most likely empty if you are modifying the quick edit window.

Arantor

Yup, and the shortcuts do not get rebound for such.

ashish101

I agree the shortcut keys must have been enabled for quick reply but when the shortcut keys are pressed during quick edit mode, generates an error. Is there any way to temporarily disable these shortcut key combinations?

kat

The part of the template, that deals with that, has a load of references to "JavaScriptEscape". So, I'd assume that some Javascript controls that.

editor.js (In the default theme's "scripts" directory) contains this:

// Register default keyboard shortcuts.
smc_Editor.prototype.registerDefaultShortcuts = function()
{
if (is_ff)
{
this.registerShortcut('b', 'ctrl', 'b');
this.registerShortcut('u', 'ctrl', 'u');
this.registerShortcut('i', 'ctrl', 'i');
this.registerShortcut('p', 'alt', 'preview');
this.registerShortcut('s', 'alt', 'submit');
}
}


I would assume that, if you remove that, the keyboard shortcuts will no longer work (You may have to empty your cache).

BUT... I'm merely kinda guessing, with all this. So, keep a backup copy of any files that you edit, in case I've just typed a load of crap.

Plus, of course, this is hardly temporary, even if it does work, and it'll affect the editor, wherever it is, I'd assume...

Arantor

Nope, it's nothing to do with that at all, unfortunately.

Quick reply defines certain shortcuts for posting, when you perform quick edit, the other shortcuts are not re-bound or cancelled out (which is why Alt-P still previews) and because Alt-S was already declared (for quick reply posting) it doesn't get re-bound for quick edit.

Fixing this is... difficult.

kat

Ah. I was on the right track. But, I seem to've been shunted onto a siding, whilst the main track is sweeping, majestically, into the distance... :(

Arantor

It's honestly nothing to do with smc_Editor. That's not even loaded on the page where quick edit is performed.

kat

Ah. :P

Well, I just did a bit of rooting around, to see what I could find (Hence the warnings).

Close-ish. But, no cigar. :)

ashish101

So where's the code for quick reply box defining these shortcut keys, maybe could do something there.

Deaks

ashish101 do you still need assistance? if so please let us know, I have marked this as solved until you get back to us :)
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

ashish101

Quote from: Μπράιαν on August 26, 2014, 06:03:42 PM
ashish101 do you still need assistance? if so please let us know, I have marked this as solved until you get back to us :)
Yeah still haven't found any solution to it.

Arantor

Your choices are telling people not to use the shortcuts, or waiting for someone to sit down and rewrite the JavaScript for the quick edit to fix this (which probably won't occur in a 2.0 patch, if I'm being honest)

ashish101

Quote from: ‽ on August 26, 2014, 08:38:25 PM
Your choices are telling people not to use the shortcuts, or waiting for someone to sit down and rewrite the JavaScript for the quick edit to fix this (which probably won't occur in a 2.0 patch, if I'm being honest)
I have already told the users that it's sort of a bug but I would still like to fix it if possible. I am happy to do some re-coding and testing, just need some guidance on which part of the code to look at.

Arantor

The code is in the QuickModify object in topic.js. Good luck, you *are* going to need it.

ashish101

Quote from: ♥ on August 26, 2014, 10:04:18 PM
The code is in the QuickModify object in topic.js. Good luck, you *are* going to need it.
Thanks, can you please point me to the code block which defines shortcut keys for quick reply box? As far as I understand editor.js is not doing anything here, right?

ashish101

Actually found the code, earlier was looking into js files only but found that the shortcut keys are set for quick reply box using accessKey.

So, did bit of tweaking in topic.js to disable these accesskeys when in quick edit mode
document.getElementsByName("preview").accessKey = '';
document.getElementsByName("post").accessKey = '';


and restore them when exiting quick edit mode.
document.getElementsByName("preview")[0].accessKey ='';
document.getElementsByName("post")[0].accessKey ='';


This would solve the issue upto an extent and any accidental ALT+P or ALT+S during quick edit mode won't result in an error. I got another solution in mind for fully "fixing" this issue but that would need modifying the quickmodify object functions which would be bit more complex.

Advertisement: