@sanity/ui 2.4.0 → 2.5.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/dist/index.d.mts CHANGED
@@ -189,6 +189,8 @@ export declare interface AutocompleteProps<
189
189
  onSelect?: (value: string) => void
190
190
  /** @beta */
191
191
  openButton?: boolean | AutocompleteOpenButtonProps
192
+ /** @beta */
193
+ openOnFocus?: boolean
192
194
  /** The options to render. */
193
195
  options?: Option[]
194
196
  padding?: number | number[]
package/dist/index.d.ts CHANGED
@@ -189,6 +189,8 @@ export declare interface AutocompleteProps<
189
189
  onSelect?: (value: string) => void
190
190
  /** @beta */
191
191
  openButton?: boolean | AutocompleteOpenButtonProps
192
+ /** @beta */
193
+ openOnFocus?: boolean
192
194
  /** The options to render. */
193
195
  options?: Option[]
194
196
  padding?: number | number[]
package/dist/index.esm.js CHANGED
@@ -4620,6 +4620,7 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4620
4620
  onQueryChange,
4621
4621
  onSelect,
4622
4622
  openButton,
4623
+ openOnFocus,
4623
4624
  options: optionsProp,
4624
4625
  padding: paddingProp = 3,
4625
4626
  popover = EMPTY_RECORD,
@@ -4715,11 +4716,16 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4715
4716
  dispatch({ type: "input/change", query: nextQuery }), onQueryChange && onQueryChange(nextQuery);
4716
4717
  },
4717
4718
  [onQueryChange]
4718
- ), handleInputFocus = useCallback(
4719
+ ), dispatchOpen = useCallback(() => {
4720
+ dispatch({
4721
+ type: "root/open",
4722
+ query: value ? renderValue(value, currentOption) : ""
4723
+ });
4724
+ }, [currentOption, renderValue, value]), handleInputFocus = useCallback(
4719
4725
  (event) => {
4720
- focused || (dispatch({ type: "input/focus" }), onFocus && onFocus(event));
4726
+ focused || (dispatch({ type: "input/focus" }), onFocus && onFocus(event), openOnFocus && dispatchOpen());
4721
4727
  },
4722
- [focused, onFocus]
4728
+ [focused, onFocus, openOnFocus, dispatchOpen]
4723
4729
  ), handlePopoverMouseEnter = useCallback(() => {
4724
4730
  popoverMouseWithinRef.current = !0;
4725
4731
  }, []), handlePopoverMouseLeave = useCallback(() => {
@@ -4765,15 +4771,12 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4765
4771
  [openButton]
4766
4772
  ), handleOpenClick = useCallback(
4767
4773
  (event) => {
4768
- dispatch({
4769
- type: "root/open",
4770
- query: value ? renderValue(value, currentOption) : ""
4771
- }), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() => {
4774
+ dispatchOpen(), openButtonProps.onClick && openButtonProps.onClick(event), _raf(() => {
4772
4775
  var _a;
4773
4776
  return (_a = inputElementRef.current) == null ? void 0 : _a.focus();
4774
4777
  });
4775
4778
  },
4776
- [currentOption, openButtonProps, renderValue, value]
4779
+ [openButtonProps, dispatchOpen]
4777
4780
  ), openButtonNode = useMemo(
4778
4781
  () => !disabled && !readOnly && openButton ? /* @__PURE__ */ jsx(Box, { "aria-hidden": expanded, padding: openButtonBoxPadding, children: /* @__PURE__ */ jsx(
4779
4782
  Button,