Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColumnConfig: Uncaught DOMExceptions if the name of ColumnConfig contains special characters, e.g. '/' #812

Closed
bschmelcher opened this issue Aug 10, 2023 · 0 comments
Assignees
Labels
bug Something isn't working version 1.x.x Version 1.x.x issues version 2.x.x Version 2.x.x issues
Projects
Milestone

Comments

@bschmelcher
Copy link

Describe the bug
If the name of a columnConfig is set to a string containing special characters, e.g. '/', a lot of UncaughtDOMExceptions are thrown.

To Reproduce
See Code to reproduce, the exception will be thrown upon loading the site.

Expected behavior
Css rules should be escaped before being applied in DominoStyleSheet.

Code to reproduce

import com.google.gwt.core.client.EntryPoint;
import elemental2.dom.Event;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.dominokit.domino.ui.cards.Card;
import org.dominokit.domino.ui.cards.HeaderAction;
import org.dominokit.domino.ui.datatable.ColumnConfig;
import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.TableConfig;
import org.dominokit.domino.ui.datatable.store.LocalListDataStore;
import org.dominokit.domino.ui.icons.Icons;
import org.dominokit.domino.ui.layout.Layout;
import org.dominokit.domino.ui.style.ColorScheme;
import org.dominokit.domino.ui.utils.TextNode;

public class CodeToReproduce implements EntryPoint {

    private LocalListDataStore<DataObject> localListDataStore;

    private DataTable<DataObject> table;

    private final TableConfig<DataObject> tableConfig = new TableConfig<>();

    private final Card card = Card.create();

    @Override
    public void onModuleLoad() {

        Layout layout = Layout.create("ColumnConfig special characters").show(ColorScheme.AMBER);

        tableConfig
                .addColumn(ColumnConfig.<DataObject>create("a/b", "a/b")
                        .setCellRenderer(
                                cell -> TextNode.of(cell.getTableRow().getRecord().getValue("a/b").toString())
                        ));

        localListDataStore = new LocalListDataStore<>();
        table = new DataTable<>(tableConfig, localListDataStore).noStripes();

        List<DataObject> data = new ArrayList<>();
        DataObject object = new DataObject()
                .addDataObject("a/b", (0));
        data.add(object);
        localListDataStore.setData(data);

        card.addHeaderAction(new HeaderAction(Icons.MDI_ICONS.refresh_mdi()).addClickListener((Event evt) -> {
            card.getBody().clearElement();
            localListDataStore = new LocalListDataStore<>();
            table = new DataTable<>(tableConfig, localListDataStore).noStripes();
            List<DataObject> data1 = new ArrayList<>();
            DataObject object1 = new DataObject()
                    .addDataObject("a/b", (1));
            data1.add(object1);
            localListDataStore.setData(data1);
            card.appendChild(table);

        }));

        card.appendChild(table);

        layout.getContentPanel().appendChild(card);

    }

    private static class DataObject {

        private final HashMap<String, Object> keyValuePair = new HashMap<>();

        public DataObject addDataObject(String key, Object value) {
            keyValuePair.put(key, value);
            return this;
        }

        public Object getValue(String key) {
            return keyValuePair.get(key);
        }
    }
}
@vegegoku vegegoku self-assigned this Aug 27, 2023
@vegegoku vegegoku added the bug Something isn't working label Aug 27, 2023
@vegegoku vegegoku added this to To do in Domino UI via automation Aug 27, 2023
@vegegoku vegegoku added version 1.x.x Version 1.x.x issues version 2.x.x Version 2.x.x issues labels Aug 27, 2023
@vegegoku vegegoku added this to the 2.0.0-RC2 milestone Aug 27, 2023
vegegoku added a commit that referenced this issue Aug 28, 2023
…nfig contains special characters, e.g. '/'
vegegoku added a commit that referenced this issue Aug 28, 2023
…nfig contains special characters, e.g. '/'
Domino UI automation moved this from To do to Done Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working version 1.x.x Version 1.x.x issues version 2.x.x Version 2.x.x issues
Projects
Domino UI
  
Done
Development

No branches or pull requests

2 participants