@@ -1146,6 +1146,7 @@ typedef struct {
11461146 Clay_LayoutConfig *layoutConfig;
11471147 Clay__ElementConfigArraySlice elementConfigs;
11481148 uint32_t id;
1149+ uint16_t floatingChildrenCount;
11491150} Clay_LayoutElement;
11501151
11511152CLAY__ARRAY_DEFINE (Clay_LayoutElement, Clay_LayoutElementArray)
@@ -1776,7 +1777,8 @@ Clay_LayoutElementHashMapItem *Clay__GetHashMapItem(uint32_t id) {
17761777Clay_ElementId Clay__GenerateIdForAnonymousElement (Clay_LayoutElement *openLayoutElement) {
17771778 Clay_Context* context = Clay_GetCurrentContext ();
17781779 Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get (&context->layoutElements , Clay__int32_tArray_GetValue (&context->openLayoutElementStack , context->openLayoutElementStack .length - 2 ));
1779- Clay_ElementId elementId = Clay__HashNumber (parentElement->childrenOrTextContent .children .length , parentElement->id );
1780+ uint32_t offset = parentElement->childrenOrTextContent .children .length + parentElement->floatingChildrenCount ;
1781+ Clay_ElementId elementId = Clay__HashNumber (offset, parentElement->id );
17801782 openLayoutElement->id = elementId.id ;
17811783 Clay__AddHashMapItem (elementId, openLayoutElement);
17821784 Clay__StringArray_Add (&context->layoutElementIdStrings , elementId.stringId );
@@ -1917,9 +1919,15 @@ void Clay__CloseElement(void) {
19171919
19181920 // Close the currently open element
19191921 int32_t closingElementIndex = Clay__int32_tArray_RemoveSwapback (&context->openLayoutElementStack , (int )context->openLayoutElementStack .length - 1 );
1922+
1923+ // Get the currently open parent
19201924 openLayoutElement = Clay__GetOpenLayoutElement ();
19211925
1922- if (!elementIsFloating && context->openLayoutElementStack .length > 1 ) {
1926+ if (context->openLayoutElementStack .length > 1 ) {
1927+ if (elementIsFloating) {
1928+ openLayoutElement->floatingChildrenCount ++;
1929+ return ;
1930+ }
19231931 openLayoutElement->childrenOrTextContent .children .length ++;
19241932 Clay__int32_tArray_Add (&context->layoutElementChildrenBuffer , closingElementIndex);
19251933 }
0 commit comments