Skip to content

Commit b9480a8

Browse files
committed
Improve behaviour of nuclide name enter on "Reference Photopeak" tab.
May be solution for issue #19 - but not checked on Linux/Windows yet. Fixed if you type a nuclide in fast and hit enter, the first item in suggested list would be entered (before it was updated from the C++), instead of what you typed. Fix erroneous error message when clicking on a suggestion from the list (the error message would say what you had typed so far was an invalid nuclide) Hopefully fixed special character handling - like the "(" not entering sometimes when trying to add a reaction. Fix selection not being visible when you use arrow to go down past visible list (when scrollbar is present). Improve handling width of suggestion popup - hopefully.
1 parent 03a34ca commit b9480a8

File tree

4 files changed

+693
-14
lines changed

4 files changed

+693
-14
lines changed

InterSpec/IsotopeNameFilterModel.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace SandiaDecay
4444

4545
namespace Wt
4646
{
47+
class WLineEdit;
4748
class WSuggestionPopup;
4849
}
4950

@@ -113,6 +114,19 @@ class IsotopeNameFilterModel : public Wt::WAbstractItemModel
113114
// we will do a hack to catch this.
114115
static void setQuickTypeFixHackjs( Wt::WSuggestionPopup *popup );
115116

117+
//Fixes multiple issues with WSuggestionPopup:
118+
// 1. Race condition: when user types quickly and hits Enter, the suggestion popup
119+
// may not have filtered yet, causing wrong suggestion to be selected. This
120+
// intercepts Enter key and checks if typed text exactly matches any suggestion,
121+
// using that match instead of the highlighted one.
122+
// 2. Arrow key navigation: ensures arrow key selection works correctly when hitting Enter.
123+
// 3. Mouse click handling: prevents premature change events when clicking suggestions,
124+
// ensuring only the final suggestion value triggers a change event.
125+
// 4. Popup hiding: automatically hides the suggestion popup when values are entered.
126+
// 5. Special character input: allows special characters like "(" to be entered without
127+
// being blocked by the suggestion popup.
128+
static void setEnterKeyMatchFixJs( Wt::WSuggestionPopup *popup, Wt::WLineEdit *edit );
129+
116130
/** By default nuclides are included in suggestions, this function allows
117131
* disabling/enabling this.
118132
*/

InterSpec_resources/InterSpec.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,3 +1698,20 @@ a:hover { color:#E88400; border-bottom:none; }
16981698
flex-direction: row;
16991699
align-items: center;
17001700
}
1701+
1702+
/* Style nuclide suggestion popup list items to be wider and full-width for easier clicking */
1703+
.nuclide-suggest
1704+
{
1705+
min-width: 80px; /* Ensure popup is at least as wide as the list items */
1706+
overflow-x: hidden; /* Prevent horizontal scrollbar when vertical scrollbar appears */
1707+
}
1708+
1709+
.nuclide-suggest li,
1710+
.nuclide-suggest .Wt-suggest-item
1711+
{
1712+
min-width: 80px;
1713+
width: 100%;
1714+
padding-left: 5px;
1715+
padding-right: 5px;
1716+
box-sizing: border-box; /* Include padding in width calculation */
1717+
}

0 commit comments

Comments
 (0)