Skip to content

Commit 8b78e87

Browse files
committed
DOC-1820: Update fetch and explanation of how the search works with fetchContext
1 parent 0c7c2a8 commit 8b78e87

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

modules/ROOT/pages/custom-menu-toolbar-button.adoc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,30 @@ include::partial$misc/admon-requires-6.4v.adoc[]
3737
|setIcon |`+(icon: string) => void+` |Sets the icon of the button.
3838
|===
3939

40-
== Menu button example and explanation
40+
== Menu button example and explanation without search
4141

4242
The following is a simple toolbar menu button example:
4343

4444
liveDemo::custom-toolbar-menu-button[tab="js"]
4545

46-
This example configures a toolbar menu button with the label `+My Button+` that opens the specified menu when clicked. The top-level menu contains two items. The first menu item inserts content when clicked and the second menu item opens a submenu containing two menu items which insert content when clicked.
46+
This example configures a toolbar menu button labeled `+My Button+` that opens a menu when clicked. The menu contains two items: one that inserts content and another that opens a submenu with two additional items to be inserted when clicked.
4747

48-
The `+fetch+` function is called when the toolbar menu button's menu is opened. It is a function that takes a callback and passes it an array of menu items to be rendered in the drop-down menu. This allows for asynchronous fetching of the menu items.
48+
The `+fetch+` function retrieves an array of menu items and passes it to the callback, which renders them in the dropdown menu. This enables asynchronous menu generation.
4949

5050
[[searchable-menu-buttons]]
5151
== Searchable menu buttons
5252

5353
include::partial$misc/admon-requires-6.2v.adoc[]
5454

55-
The button's menu can be configured to have an input field for searching, as well as its usual items. The presence of the input field is controlled by the `+search+` field in the xref:options[options]. The `+search+` field can be a `+boolean+` or an `+object+` containing a single optional string `placeholder`. By default, `+search+` is false. If `+search+` is not false, the button's menu will contain an input field with any specified placeholder text. As the user types into this field, the `+fetch+` function will be called with the text in the input field passed back as part of `+fetchContext+`. The `+fetch+` function is responsible for using this `+fetchContext+` to determine which items to pass to its `+success+` callback.
55+
The button's menu can include a search input field alongside it's items, controlled by the `+search+` option. The `+search+` option can be either:
5656

57-
The `+fetchContext+` is an object containing a single string property: `+pattern+`. If the toolbar menu button has not configured `search` to be active, then the `+pattern+` string will be empty.
57+
* A `+boolean+` value: When `true`, it enables the search field. The text inside the field is empty.
5858

59+
* An `+object+`: Allows customization with a placeholder to set placeholder text for the input field.
60+
61+
By default, `+search+` is false, meaning no search field is displayed. When enabled, the search field allows for dynamic updating of the menu content based on their input. The `+fetchContext+` object provides additional information to the `+fetch+` function which can be used to determine the menu's behaviour or content.
62+
63+
When `+search+` is enabled, depending on the `+pattern+` property of `+fetchContext+` different menu buttons options will be shown. This is because when a new keypress is added to the `+search+`, `+fetch+` is called to update the possible options from the search.
5964
== Searchable menu button example and explanation
6065

6166
include::partial$misc/admon-requires-6.2v.adoc[]

0 commit comments

Comments
 (0)