Repository: DevExpress/devextreme-react (js)

Issue:
DxLookup.FieldComponent rendered incorrectly
<!-- *************************************************************************************************
To reduce the time it takes to process issues, search opened and closed tickets in our support center (https://www.devexpress.com/Support/Center/Question/List/1) before you submit a new issue. The tickets can contain resolutions, workarounds, or information about fixes.

You can also find information that can help you to resolve the issue in the following resources:

    - https://github.com/DevExpress/devextreme-react/blob/master/README.md
******************************************************************************************************* -->

# Bug Report

<!-- Please provide the following information -->

**Package versions:**

    devexteme version: ^18.2.4
    devextreme-react version: ^18.2.4

**Steps to reproduce:**
<!-- Provide a sample application that illustrates the bug if possible. You can use the following services: 
    - GitHub
    - StackBlitz (https://stackblitz.com/edit/devextreme-react-htjbnz)
-->
https://stackblitz.com/edit/devextreme-react-tqwbf7?file=package.json

**Current behavior:**
<!-- Describe how the bug manifests. -->
There are two strange inputs in lookups field with strange paddings.
**Expected behavior:**
<!-- Describe what you expect to happen. -->
Only one input without paddigns.
**Screenshots:**
<!-- Add screenshots that demonstrate your problem if possible. -->
![image](https://user-images.githubusercontent.com/12596197/52552560-cb23cc80-2df1-11e9-9473-7ad1fa7b1d0e.png)


Pull request:
Fix twice rendered templates issue
Fixes #306 

Patch:
diff --git a/src/core/template-host.ts b/src/core/template-host.ts
index 136c42a..aa9d8ec 100644
--- a/src/core/template-host.ts
+++ b/src/core/template-host.ts
@@ -131,10 +131,18 @@ function wrapTemplate(
     stateUpdater: StateUpdater,
     keyFn?: (data) => string
 ): IDxTemplate {
+
+    const renderedContainers: HTMLElement[] = [];
     return {
         render: (data: IDxTemplateData) => {
             const templateId = keyFn ? keyFn(data.model) : "__template_" + generateID();
             const container = unwrapElement(data.container);
+
+            if (renderedContainers.indexOf(container) > -1) {
+                return container;
+            }
+            renderedContainers.push(container);
+
             const createWrapper = () => {
                 const model = data.model;
                 if (model && model.hasOwnProperty("key")) {
@@ -163,3 +171,6 @@ function unwrapElement(element: any) {
 }
 
 export default TemplateHost;
+export {
+    wrapTemplate
+};


Test patch:
diff --git a/src/core/__tests__/template-host.test.tsx b/src/core/__tests__/template-host.test.tsx
new file mode 100644
index 0000000..d35052b
--- /dev/null
+++ b/src/core/__tests__/template-host.test.tsx
@@ -0,0 +1,28 @@
+import { wrapTemplate } from "../template-host";
+
+describe("template-host", () => {
+
+    describe("its wrapped template", () => {
+
+        it("doesn't render twice into the same container", () => {
+            const updateFunc = jest.fn();
+            const container: any = {};
+            const template = wrapTemplate(
+                jest.fn(),
+                updateFunc,
+                jest.fn()
+            );
+
+            template.render({
+                container
+            });
+
+            template.render({
+                container
+            });
+
+            expect(updateFunc).toHaveBeenCalledTimes(1);
+        });
+    });
+
+});