@xsolla/xui-context-menu 0.237.0 → 0.239.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -178,6 +178,8 @@ When the option list overflows `maxHeight`, the search cell stays pinned to the
178
178
  </ContextMenu>
179
179
  ```
180
180
 
181
+ The pinned header covers the panel's own padding too: its surface extends over the panel's side padding, and over the top padding when the search cell is the first item. Options that scroll under the header do not show through the gaps around it. With `withArrow` the options scroll in an inner container inside the panel padding, so no extension is needed. With `noPadding` there is no panel padding to cover.
182
+
181
183
  The panel detects the search cell among its direct children only. A search cell nested inside a fragment or your own wrapper component is not pinned — render it directly under `<ContextMenu>`.
182
184
 
183
185
  ### `type="heading"`
package/native/index.js CHANGED
@@ -1815,20 +1815,33 @@ var ContextMenuRoot = (0, import_react6.forwardRef)(
1815
1815
  );
1816
1816
  };
1817
1817
  const renderedItems = searchable ? filterItems(items, debouncedQuery) : [...items];
1818
- const renderStickySearch = (node, key) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1819
- "div",
1820
- {
1821
- "data-sticky": "top",
1822
- style: {
1823
- position: "sticky",
1824
- top: 0,
1825
- zIndex: 1,
1826
- backgroundColor: surfaceColor
1818
+ const stickyBleedHorizontal = withArrow ? 0 : panelPaddingHorizontal;
1819
+ const stickyBleedTop = withArrow ? 0 : panelPaddingVertical;
1820
+ const renderStickySearch = (node, key, isFirst = true) => {
1821
+ const bleedTop = isFirst ? stickyBleedTop : 0;
1822
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1823
+ "div",
1824
+ {
1825
+ "data-sticky": "top",
1826
+ style: {
1827
+ position: "sticky",
1828
+ // Sticks to the scrollport edge, not the content edge; the
1829
+ // padding below keeps the panel's breathing room above the cell.
1830
+ top: 0,
1831
+ zIndex: 1,
1832
+ backgroundColor: surfaceColor,
1833
+ marginTop: -bleedTop,
1834
+ marginLeft: -stickyBleedHorizontal,
1835
+ marginRight: -stickyBleedHorizontal,
1836
+ paddingTop: bleedTop,
1837
+ paddingLeft: stickyBleedHorizontal,
1838
+ paddingRight: stickyBleedHorizontal
1839
+ },
1840
+ children: node
1827
1841
  },
1828
- children: node
1829
- },
1830
- key
1831
- );
1842
+ key
1843
+ );
1844
+ };
1832
1845
  const searchHeader = searchable ? renderStickySearch(
1833
1846
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1834
1847
  ContextMenuItem,
@@ -1848,10 +1861,13 @@ var ContextMenuRoot = (0, import_react6.forwardRef)(
1848
1861
  if (!import_react6.default.Children.toArray(children).some(isSearchCellElement)) {
1849
1862
  return children;
1850
1863
  }
1851
- return import_react6.default.Children.map(
1852
- children,
1853
- (child, index) => isSearchCellElement(child) ? renderStickySearch(child, `context-menu-search-${index}`) : child
1854
- );
1864
+ let renderedBefore = false;
1865
+ return import_react6.default.Children.map(children, (child, index) => {
1866
+ const isFirst = !renderedBefore;
1867
+ if (child !== null && child !== void 0 && typeof child !== "boolean")
1868
+ renderedBefore = true;
1869
+ return isSearchCellElement(child) ? renderStickySearch(child, `context-menu-search-${index}`, isFirst) : child;
1870
+ });
1855
1871
  };
1856
1872
  const renderContent = () => {
1857
1873
  if (loading || isLoading || type === "loading") {