# container.clipChildren is not working for grid?

**URL:** <https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794>\
**Category:** Bugs\
**Created:** [April 26, 2019, 10:57am UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794 "2019-04-26T10:57:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nodragem](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Nodragem](https://forum.babylonjs.com/u/Nodragem)\
**Post date:** [April 26, 2019, 10:57am UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/1 "2019-04-26T10:57:38Z")

</div>

Hello,

I’m using a grid to make my menu. It seems that the shadow of my controls is cropped by the cell of the grid, even thought I changed grid.clipChildren to false.

See my code here:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/d/d318456db9a84ed0efb5ab9be222c3e8bc0a7b5e.png)

Here the results:  
 ![chrome_2019-04-26_11-26-42](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/9/9d3517a73b6cc63693975aa7f50d6ffbddcd1e8a.png)

I tried to make a playground but for some reason my function createGrid does not work in the playground 😕

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 26, 2019, 2:12pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/2 "2019-04-26T14:12:59Z")

</div>

We are almost done with 4.0 but if you can share a repro ASAP I will fix it for you  
drop your code in a PG even if it is not working

---

<div class="post-metadata">

**Author:** ![Nodragem](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Nodragem](https://forum.babylonjs.com/u/Nodragem)\
**Post date:** [April 27, 2019, 1:45pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/3 "2019-04-27T13:45:49Z")

</div>

Hello!  
thank you very much for replying so quickly.

Here is the PG:  
[https://playground.babylonjs.com/ts.html#DK7M9T#10](https://playground.babylonjs.com/ts.html#DK7M9T#10)

It seems that my GridHelper is not working anymore with the new release candidate… is this due to the ValueAndUnit type? I don’t know, but my code should be creating a 5 by 5 grid with alternating dark/white rectangles.

Although the GridHelper is not working, we can still see the shadow issue: the shadow of the black rectangle is clipped.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 27, 2019, 5:27pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/4 "2019-04-27T17:27:32Z")

</div>

Ok so the TypeScript Playground has a bug with the GUI definition but your code compiles (The errors are wrongly reported)

But your main problem is that you are adding the rectangles in more than one cell. A control can only belong to one single cell (I will add a warning).  
I gave them name and you can see that they are in half of the cells:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/0/08fa1b62aa434588056b815e55d438659f54e4b1.png)

---

<div class="post-metadata">

**Author:** ![Nodragem](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Nodragem](https://forum.babylonjs.com/u/Nodragem)\
**Post date:** [April 27, 2019, 8:03pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/5 "2019-04-27T20:03:53Z")

</div>

Oh, I see, I think it was working some time ago but it makes sense that it should not…

Is it possible to clone a Control/Container? so that I can use rect1 and rect2 as template and I would clone them when I add them to the grid. Something like that:

```auto
let cellObject = [rect1, rect2]
let index = 0;
for (row = 0; row < nrow; row++){
      for (col = 0; col < ncol; col++){
            index = (row*ncol+col%ncol) % cellObject.length;
            grid.addControl(cellObject[index].clone(), row, col);     
      }
}

```

---

<div class="post-metadata">

**Author:** ![Nodragem](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Nodragem](https://forum.babylonjs.com/u/Nodragem)\
**Post date:** [April 27, 2019, 8:09pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/6 "2019-04-27T20:09:37Z")

</div>

It seems that you actually get the behaviour I was expecting (even if it is “wrong”): to have the same object in several cells.

On my side the inspector looks like that:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/1/132a649edd4a752ee340424ac236f078504fe915.png)

But anyway we are drifting away from the main issue of the thread which is: **Can we deactivate shadow/object clipping within the grid cells** 😃 ?!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 27, 2019, 8:28pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/8 "2019-04-27T20:28:26Z")

</div>

it works now because I pushed my fix (check your console to see the warning message)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 27, 2019, 9:21pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/9 "2019-04-27T21:21:38Z")

</div>

and here we are:  
[https://playground.babylonjs.com/ts.html#DK7M9T#12](https://playground.babylonjs.com/ts.html#DK7M9T#12)

I’ve added clipContent for you 🙂

---

<div class="post-metadata">

**Author:** ![Nodragem](https://avatars.discourse-cdn.com/v4/letter/n/3be4f8/32.png) [@Nodragem](https://forum.babylonjs.com/u/Nodragem)\
**Post date:** [April 28, 2019, 9:44pm UTC](https://forum.babylonjs.com/t/container-clipchildren-is-not-working-for-grid/2794/10 "2019-04-28T21:44:55Z")

</div>

That is amazingly useful 😃 We can now organise GUI elements with a grid without worrying too much about the grid!
