Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    CanvasItem cell editor not hidden when tabbing to next cell

    Isomorphic,

    When using a CanvasItem for a custom cell editor, the editor doesn't get hidden when tabbing out of the cell.

    You can see this by modifying the Custom Cell Editors Showcase sample.

    Use the following modified getData() method.

    Code:
     private ListGridRecord[] getData() {
            return new ListGridRecord[] { new NameValueRecord(1, "String Editor", "some string"), new NameValueRecord(2, "Password Editor", "donkeykong"),
                    new NameValueRecord(3, "Date Editor", new Date()), new NameValueRecord(4, "Boolean Editor", Boolean.FALSE),
                    new NameValueRecord(5, "Masked Int Editor", 5), new NameValueRecord(6, "SelectItem Editor", "Dog"),
                    new NameValueRecord(7, "Slider Editor", 7), new NameValueRecord(8, "String Editor", "some other string") };
        }
    Steps to reproduce:

    1. From the list grid, edit the Value Field for the Slider Editor record.
    2. Move the slider, then hit the TAB key.

    The focus will change to the Value Field for the next row, however, the Slider component will still be visible and there is no way to get rid of it.

    Click image for larger version

Name:	custom_cell_editor.jpg
Views:	49
Size:	13.0 KB
ID:	268989

    SmartClient Version: v12.1p_2022-06-16/Pro Deployment (built 2022-06-16)
    Windows 10 Home
    Firefox 106.0.4 (64-bit)
    Chrome 107.0.5304.88 (Official Build) (64-bit)

    Thanks

    #2
    Thanks for the notification. We are reproducing the problem and have a developer assigned to look.

    Regards
    Isomorphic Software

    Comment


      #3
      We've made a change that should address this issue. Please try the next nightly build, dated Nov 8 or above.
      The fix has been applied to SmartGWT builds 12.1 and above.

      Regards
      Isomorphic Software

      Comment


        #4
        This issue is now resolved. Thanks!

        Comment


          #5
          Isomorphic,

          I noticed the following warning is getting logged to the SmartClient Developer Console:

          Code:
          The existing FormItem wrapper of type com.smartgwt.client.widgets.form.fields.TextItem and name: value is being replaced with a wrapper of type com.smartgwt.client.widgets.form.fields.CanvasItem to match the type of the underlying SmartClient instance.  Continuing to use the old wrapper (by reference) may lead to invalid behavior.  Call setWarnOnEditorTypeConversion() to supress the warning for this item, or setWarnOnEditorTypeConversionDefault() to suppress it by default for all subsequently created items.
          The following simplified CanvasItem can be used to produce the warning. The warning is logged when form.getCanvasItem() is called by the changed handler. Is there something I should be doing differently to get access to the CanvasItem instance?

          Code:
           public static class SimpleCanvasItem extends CanvasItem {
                  public SimpleCanvasItem() {
                      setShouldSaveValue(Boolean.TRUE);
                      setWarnOnEditorTypeConversion(false);
          
                      DynamicForm form = new DynamicForm();
                      SelectItem colorItem = new SelectItem("color");
                      colorItem.setShowTitle(Boolean.FALSE);
                      colorItem.setValueMap("red", "blue", "green");
                      colorItem.addChangedHandler(event -> form.getCanvasItem().storeValue(event.getValue()));
                      form.setItems(colorItem);
          
                      setCanvas(form);
                  }
              }
          Thanks


          Comment


            #6
            We're not reproducing that warning with your sample code. Could you provide modified code from an existing SmartGWT (LGPL or Eval) sample that generates that warning?

            You're using SmartGWT 12.1, right? Have you tried with the latest patch build? That's actually required when reporting a bug here. Finally, what version of GWT are you using?

            Comment


              #7
              Isomorphic,

              I am using SmartClient Version: v12.1p_2022-11-08/Pro Deployment (built 2022-11-08) and GWT 2.9.0.

              Here is the complete modified sample that generates the warning. If you Edit the Value Field for the Custom Editor row and select an option the warning will be generated.

              Code:
                  public void onModuleLoad() {
                      ListGridField nameField = new ListGridField("name", "Name");
                      nameField.setWidth("*");
                      nameField.setCanEdit(false);
              
                      ListGridField valueField = new ListGridField("value", "Value Field", 170);
              
                      ListGrid countryGrid = new ListGrid();
                      countryGrid.setWidth(300);
                      countryGrid.setHeight(340);
                      countryGrid.setShowAllRecords(true);
                      countryGrid.setFields(nameField, valueField);
                      countryGrid.setData(getData());
                      countryGrid.setEditorCustomizer(context -> {
                          ListGridField field = context.getEditField();
                          if (field.getName().equals("value")) {
                              NameValueRecord record = (NameValueRecord) context.getEditedRecord();
                              int id = record.getID();
                              switch (id) {
                                  case 1:
                                      return new SimpleCanvasItem();
                                  default:
                                      return context.getDefaultProperties();
                              }
                          }
                          return context.getDefaultProperties();
                      });
                      countryGrid.setCanEdit(true);
                      countryGrid.setEditEvent(ListGridEditEvent.CLICK);
                      countryGrid.setEditByCell(true);
                      countryGrid.draw();
                  }
              
                  private ListGridRecord[] getData() {
                      return new ListGridRecord[] { new NameValueRecord(1, "Custom Editor", null) };
                  }
              
                  public static class SimpleCanvasItem extends CanvasItem {
                      public SimpleCanvasItem() {
                          setShouldSaveValue(Boolean.TRUE);
                          setWarnOnEditorTypeConversion(false);
              
                          DynamicForm form = new DynamicForm();
                          SelectItem colorItem = new SelectItem("color");
                          colorItem.setShowTitle(Boolean.FALSE);
                          colorItem.setValueMap("red", "blue", "green");
                          colorItem.addChangedHandler(event -> form.getCanvasItem().storeValue(event.getValue()));
                          form.setItems(colorItem);
              
                          setCanvas(form);
                      }
                  }
              
                  public static class NameValueRecord extends ListGridRecord {
              
                      public NameValueRecord(int id, String name, Object value) {
                          setID(id);
                          setName(name);
                          setValue(value);
                      }
              
                      public void setID(int id) {
                          setAttribute("ID", id);
                      }
              
                      public int getID() {
                          return getAttributeAsInt("ID");
                      }
              
                      public void setValue(Object value) {
                          setAttribute("value", value);
                      }
              
                      public Object getValue() {
                          return getAttributeAsObject("value");
                      }
              
                      public void setName(String name) {
                          setAttribute("name", name);
                      }
              
                      public String getName() {
                          return getAttribute("name");
                      }
                  }
              Thanks

              Comment


                #8
                We've made a change to SGWT 12.1+ to avoid the warning. The fix will be in the builds dated 2022-11-14 and beyond.

                Comment


                  #9
                  I'm no longer seeing the warning with the Nov 14 build. Thanks!

                  Comment

                  Working...
                  X