Project

General

Profile

Actions

Bug #1042

closed

WSuggestionPopup with WInPlaceEdit: suggestions 'jump' on click, so selecting an incorrect suggestion

Added by Rob Van Dyck about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
10/28/2011
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I'm seeing something strange when the suggestions appear right on top of a WInPlaceEdit. It appears the suggestions 'jump' a few pixels up when clicking, and thereby make me select the wrong suggestion.

I'll attach 2 screenshots to clarify the issue. On both screenshots I had my mouse pointer on the lower end of the 'testa1' suggestion. I then pressed 'Print Screen' (without clicking). As you can see in the screenshot of chrome, I'm actually hovering over 'testa2' instead of 'testa1', because the suggestionbox has moved up the screen. On Firefox the jump hasn't happened yet. You can also see this 'jump' in action on chrome and firefox by hovering over a suggestion and then KEEPING your left mouse button PRESSED IN. You will not select anything, but you will see the 'jump'.

I'll attach the source code to reproduce the issue. To reproduce this: MAKE SURE YOUR SUGGESTIONS ARE RIGHT ON TOP OF THE WInPlaceEdit! I did this by enabling the 'developer tools' on chrome, or enabling the 'firebug' extension on firefox, both on the bottom of the screen.

You will not be able to reproduce this if the suggestions appear below the WInPlaceEdit, or floating free at the top of the screen.

   WContainerWidget *cont = new WContainerWidget(root());

   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);
   new WBreak(cont);

   Wt::WSuggestionPopup::Options contactOptions = { "<b>",         // highlightBeginTag
     "</b>",        // highlightEndTag
     ' ',           // listSeparator      (for multiple addresses)
     " ",        // whitespace
     "-., /\"@\\n;", // wordSeparators     (within an address)
     ""           // appendReplacedText (prepare next email address)
    };
   Wt::WSuggestionPopup *testpopup = new Wt::WSuggestionPopup(contactOptions, cont);

    Wt::WInPlaceEdit *edit = new Wt::WInPlaceEdit("1234", cont);
    edit->setEmptyText("empty");

    WStandardItemModel *model = new WStandardItemModel();
    testpopup->setMaximumSize(WLength(400, WLength::Pixel), WLength(210, WLength::Pixel));
    testpopup->setMinimumSize(WLength(400, WLength::Pixel), WLength(210, WLength::Pixel));
    testpopup->setModel(model);
    testpopup->activated().connect(bind(&HelloApplication::line_edit_changed, this, _1, edit, testpopup));
    edit->setButtonsEnabled(false);
    testpopup->forEdit(edit->lineEdit(), WSuggestionPopup::PopupTrigger::DropDownIcon | WSuggestionPopup::PopupTrigger::Editing);
    testpopup->setFilterLength(0);
    testpopup->addSuggestion("testa1", "testb1");
    testpopup->addSuggestion("testa2", "testb2");
    testpopup->addSuggestion("testa3", "testb3");
    testpopup->addSuggestion("testa4", "testb4");
    testpopup->addSuggestion("testa5", "testb5");
    root()->addWidget(cont);

void HelloApplication::line_edit_changed(int selected, WInPlaceEdit *edit, WSuggestionPopup *popup)
{
   std::string new_data__ = (asString(popup->model()->data(selected, Wt::DisplayRole))).toUTF8();
   cout << "\nnew data: " << new_data__ << "\n";
   edit->textWidget()->setText(new_data__);
   edit->lineEdit()->setText(new_data__);
}

FYI: I'm using version 3.1.11

Thanx for your great framework!


Files

Actions #1

Updated by Koen Deforche about 13 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche
  • Target version set to 3.2.0

Hey Rob,

I've traced the jumping behavior back to the fact that the height of the 'page' changes. The popup is positioned absolutely relative to the bottom of the page (using CSS "bottom: xx px").

I thus suggest to work around this issue by making sure that the fact that an in place edit changes from line edit to text does not change its height, or at least not the height of the page (e.g. by putting it in a container widget with a set height).

Regards,

koen

Actions #2

Updated by Koen Deforche about 13 years ago

  • Status changed from Feedback to Closed

I'm not sure we can fix this any better than the work around does it.

Actions

Also available in: Atom PDF