miniBB ®

miniBB

®
Support Forums
  
 · Start · Sign in · Register · Search · Statistics · File Bank · Manual ·
Bugs miniBB Support Forums / Bugs /  
 

The Quote is pasting the previously highlighted text if clicked multiple times

 
 
Page  Page 2 of 2 :  « Previous  1  2

Author tom322
Active Member
#16 · Posted: 4 Sep 2026 15:50
Yes, I could repeat this when I follow the steps (in Firefox). Even though I almost never select text using a keyboard, just the mouse... I think it's more to do with not fully clearing text in the insertAtCursor function after clicking on the bold, etc. button.

Author Paul
Lead Lead Developer
#17 · Posted: 4 Sep 2026 20:18
tom322:
I think it's more to do with not fully clearing text in the insertAtCursor function after clicking on the bold, etc. button.
I could just expect so far, it's about another method of selection... and it's in another function, not in insertAtCursor.

Do you have alternative habits of how to highlight the text, except with the keyboard like I provided?.. perhaps double/triple clicking the text or similar.

Author tom322
Active Member
#18 · Posted: 4 Sep 2026 20:41
In most cases, I use text highlighting with a mouse. But when I write something in a form, I use a delete/backspace buttons too. I often write some text, then use the Bold or Italic button on some selected text (I then may use the Shift + array button to select the text I need). So this combination may cause the issue..

Author Paul
Lead Lead Developer
#19 · Posted: Yesterday 15:16
After more tests, I could conclude that the issue is in form.jsgetSelectionText() function and two event listeners — 'mouseup' and 'touchend'.

These codes are responsible for the mouse operations. When the left button is hold, the text is selected and then the left button is released, the code remembers the start and end position of the selected text. This data is used later when calculating what portion of text should be surrounded by a certain BB-code.

If you select some text with the mouse, then click Delete or Backspace button to delete it, the text is still kept in memory as being selected, and is not reset to an empty state. That's why if after that any BB-code button is clicked, the deleted text will appear between BB-code-tags.

insertAtCursor() function appears to work properly, 'cause it resets selektionEvent value to an empty after any BB-code is applied.

But with the getSelectionText() function there's a dilemma... I could possibly code additional events with catch delete/backspace, but it's not really universal method — selected text could be deleted inserting or pasting another text over it.

So, the question actually remains — how to properly reset the selection to an empty value, without affecting the other text manipulations.

Author Paul
Lead Lead Developer
#20 · Posted: Yesterday 16:20
So, for the Delete/Backspace events, you can try to add the following to form.js — let me know if it worked:

— Above document.addEventListener('mouseup', function(){ add the following function:

function handleKeyDown(event) {
if (event.key === "Delete" || event.key === "Backspace") {
selektionEvent='';
myField.focus();
}
}
— Above function insertAtCursor... add the following:

document.addEventListener("keydown", handleKeyDown);
That probably should fix 90% of cases when the selection is not reset — but now it will be after Delete or Backspace keyboard's button pressed.

Author tom322
Active Member
#21 · Posted: Yesterday 17:56
I have customized form scripts, but I tested it on a non-customized site and it seems to work (even though from my experience it appeared randomly so I wouldn't be surprised that I encounter this problem again). But for now it works, I tested only in Firefox.

I've also played with an example JS concept like below from AI and for now I don't see a problem, even though I'm not very active at posting right now:

function captureAndResetSelection() {
// 1. ALWAYS get the live, absolute freshest text on the screen
const selection = window.getSelection();
const selectedText = selection.toString();

if (selectedText.trim().length > 0) {
// 2. Paste it into your form input
document.getElementById("yourFormInputId").value = selectedText;

// 3. THE RESET: Force the browser to forget the highlight completely
// This stops old highlights from bleeding into your bolding/editing actions
selection.removeAllRanges();
}
}

Author Paul
Lead Lead Developer
#22 · Posted: Yesterday 20:58
tom322:
it appeared randomly so I wouldn't be surprised that I encounter this problem again
Whatever I could be sure at this stage — it could not be a random issue, it has an algorithm in background, which you have just to catch and follow.

captureAndResetSelection() is not truly about how miniBB operates on BB buttons/codes, but the basics are similar. Still, it's not a solution to the issue discussed here.

Page  Page 2 of 2 :  « Previous  1  2 
Bugs miniBB Support Forums / Bugs /
 The Quote is pasting the previously highlighted text if clicked multiple times
Share Link Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.