@acusti/dropdown 1.0.0-alpha.2 → 1.0.0-alpha.3

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
@@ -266,6 +266,14 @@ type Props = {
266
266
  onMouseDown?: (event: React.MouseEvent<HTMLElement>) => unknown;
267
267
  onMouseUp?: (event: React.MouseEvent<HTMLElement>) => unknown;
268
268
  onOpen?: () => unknown;
269
+ /**
270
+ * Opens the dropdown when the pointer hovers the trigger, and closes it a
271
+ * short moment after the pointer leaves the trigger and body entirely (the
272
+ * close is delayed so crossing the gap between them, or pausing over
273
+ * either, doesn’t flicker-close it). Click and keyboard opening keep
274
+ * working as usual alongside it.
275
+ */
276
+ openOnHover?: boolean;
269
277
  /**
270
278
  * Called when an item is selected. The payload includes:
271
279
  * - element: The DOM element that was clicked
@@ -427,6 +435,29 @@ function MultiSelectDropdown() {
427
435
  }
428
436
  ```
429
437
 
438
+ ### Open on Hover
439
+
440
+ ```tsx
441
+ function HoverMenu() {
442
+ return (
443
+ <Dropdown openOnHover>
444
+ <button type="button">Account</button>
445
+ <ul>
446
+ <li>Profile</li>
447
+ <li>Settings</li>
448
+ <li>Sign out</li>
449
+ </ul>
450
+ </Dropdown>
451
+ );
452
+ }
453
+ ```
454
+
455
+ Click and keyboard opening (Enter/Space while focused) still work —
456
+ hovering is an additional way in, not a replacement. This makes the most
457
+ sense for a dropdown whose body is inspectable at a glance (a short menu, a
458
+ preview card); for anything the user needs to click into, keep the default
459
+ click-to-open behavior so a stray hover doesn’t pop it open.
460
+
430
461
  ### Dropdown with Interactive Content
431
462
 
432
463
  For dropdowns whose body is a form (inputs, date pickers, buttons that
@@ -645,9 +676,11 @@ Most props keep their meaning, scoped to the submenu:
645
676
  - `className`/`style`: applied to the parent item element
646
677
 
647
678
  Props that only make sense at the top level (`allowCreate`, `allowEmpty`,
648
- `isOpenOnMount`, `isSearchable`, `keepOpenOnSubmit`, `name`, `placeholder`,
649
- `tabIndex`, `value`) are ignored on a nested dropdown and warn
650
- (unconditionally, matching the children-count misuse error).
679
+ `isOpenOnMount`, `isSearchable`, `keepOpenOnSubmit`, `name`, `openOnHover`,
680
+ `placeholder`, `tabIndex`, `value`) are ignored on a nested dropdown and
681
+ warn (unconditionally, matching the children-count misuse error). A submenu
682
+ already discloses on hover intent — see [Submenus](#submenus) — so
683
+ `openOnHover` has nothing to add there.
651
684
 
652
685
  ### Submenu placement and styling
653
686
 
@@ -57,6 +57,14 @@ export type Props = {
57
57
  onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;
58
58
  onOpen?: () => unknown;
59
59
  onSubmitItem?: (payload: Item) => void;
60
+ /**
61
+ * Opens the dropdown when the pointer hovers the trigger, and closes it a
62
+ * short moment after the pointer leaves the trigger and body entirely (the
63
+ * close is delayed so crossing the gap between them, or pausing over
64
+ * either, doesn’t flicker-close it). Click and keyboard opening keep
65
+ * working as usual alongside it.
66
+ */
67
+ openOnHover?: boolean;
60
68
  /**
61
69
  * Only usable in conjunction with {isSearchable: true}.
62
70
  * Used as search input’s placeholder.