When the Find bar is opened, its contents are selected with a delay

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Dariush

When the Find bar is opened, its contents are selected with a delay

Unread post by Dariush » 2017-12-19, 16:19

When you press Ctrl+F to open the find bar, it appears and selects all its contents so when you type, the previous contents are erased. However, when the browser is under load (many tabs opened, many tabs being loaded at once, high CPU usage) there is a noticeable delay before this selection, so if a user begins typing quickly after pressing Ctrl+F before the text is selected, undesirable behavior may happen - the new text may get appended to the old text, or the first few symbols may get appended and then everything will get selected and erased by the next keypress, so the end result is the new string without the first few symbols.

Would it be possible to either make sure all text is selected the moment find bar appears (so it's impossible to type anything before the full selection happens) or else make any keypress erase the current contents of the search field?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35481
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When the Find bar is opened, its contents are selected with a delay

Unread post by Moonchild » 2017-12-19, 18:12

If the browser is under extremely heavy load, no matter which approach is chosen, if the user is too quick to start typing it will cause issues. This cannot be changed because of the way the UI and the find bar works. If you know the browser is under extremely heavy load, give it enough time to process data. Under any sort of normal circumstances this selecting of the previous search text is instantaneous, so it would have to be a very extreme case.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Dariush

Re: When the Find bar is opened, its contents are selected with a delay

Unread post by Dariush » 2017-12-19, 22:46

I listed CPU usage as just one of what I consider to be causes of general "load". I have a ton of addons and many tabs, so my RAM usage is typically 2-3 Gb, while CPU is generally at <5%, and I usually have no problems with browser functionality.

The issue is that somehow the keypress gets handled before the previous content is selected. There is already a handler for Individual keypresses (line 80 here), so wouldn't fixing this be as simple as making sure that the contents were already selected before the entry of new text is handled?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35481
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: When the Find bar is opened, its contents are selected with a delay

Unread post by Moonchild » 2017-12-19, 23:52

You seem to forget that all of this is event-driven. "making sure x happens before y" is not straightforward in event-driven systems. The text gets selected when the bar is painted and initialized - during that time, a user may have triggered a keypress event. We don't want to block those keypress events either because then you'd get the frustrating situation that keypresses are "eaten" by the browser.
If you have a good idea how to handle this, I'm all ears, though.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Locked