Incremental capture order can be strange

I set up org protocol and a Firefox bookmarklet

javascript:location.href = ‘org-protocol://roam-ref?ref=’ + encodeURIComponent(location.href) + ‘&title=’ + encodeURIComponent(document.title) + ‘&body=’ + encodeURIComponent(window.getSelection())

(I removed “template=r&” when I was trying two templates with one bookmarklet. I don’t think it’s an issue but I stand to be corrected.) Corresponding capture template is

(setq org-roam-capture-ref-templates
'((“r” “ref” plain
;;“* ${Topic}\n%i\n\n%?”
“\n%i\n\n%?”
:target
(file+head “web/${slug}.org” “#+title: ${title}\n#+created: %T\n”)
:unnarrowed t)
))

Generally works as expected, except that the blank space before %i is ignored. (I assume there is a setting for that that I can find.) It works as expected even when I run the bookmarklet multiple times; say I do it on para 1, then para 2, then para 3. The paragraphs will be inserted into the note in that order.

The strangeness occurs when I uncomment the line with the heading (“* ${Topic} etc.”) in the capture template, and comment the line below it. Then running it multiple times, first highlighting para 1, then para 2, then para 3 will get me a note that looks like
Title 1
para 1
Title 3
para 3
Title 2
para 2

The fourth capture will drop a paragraph between 1 and 3, and so on. The order is disturbing, but I cannot figure out what is going on. It seems like a bug.

I think it may have something to do with the bookmark in the file (org-capture-last-stored). Any idea what is going on?

I think I don’t like the way things go with the headings anyway, so I will go back to my original capture template above which works well enough and doesn’t have awkward delays while I try to find the frame and enter the topic. (I am now going to try to figure out how to raise and focus the frame consistently when capturing from a web page, but that’s another issue.)