-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Runtime field editor] Preview field against cluster data #101398
Changes from all commits
17f94dc
e96e33f
cd80e34
9648e3e
94aaf37
d265e1b
60579cd
b6b0eb6
17c9a22
9f88c22
a8d79a0
6732fdd
c31b315
e5395a0
f9a6fad
5fea64e
64de3e8
3e31852
5b09833
798d4a9
e581514
97c18a2
4c05e3a
a7990ce
1970973
230100b
c5c5d73
5e677e8
0386a9b
6febb54
bdbe126
639b381
871b065
751a0d1
7b69cc4
2d3e21e
2072ebe
ba0605a
83007f7
3be4625
ca73545
8f33eb0
f7cf0ed
6b4b8d1
eea8a9a
400550f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [OverlayFlyoutOpenOptions](./kibana-plugin-core-public.overlayflyoutopenoptions.md) > [hideCloseButton](./kibana-plugin-core-public.overlayflyoutopenoptions.hideclosebutton.md) | ||
|
||
## OverlayFlyoutOpenOptions.hideCloseButton property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
hideCloseButton?: boolean; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [OverlayFlyoutOpenOptions](./kibana-plugin-core-public.overlayflyoutopenoptions.md) > [onClose](./kibana-plugin-core-public.overlayflyoutopenoptions.onclose.md) | ||
|
||
## OverlayFlyoutOpenOptions.onClose property | ||
|
||
EuiFlyout onClose handler. If provided the consumer is responsible for calling flyout.close() to close the flyout; | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
onClose?: (flyout: OverlayRef) => void; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,12 @@ export interface OverlayFlyoutOpenOptions { | |
'data-test-subj'?: string; | ||
size?: EuiFlyoutSize; | ||
maxWidth?: boolean | number | string; | ||
hideCloseButton?: boolean; | ||
/** | ||
* EuiFlyout onClose handler. | ||
* If provided the consumer is responsible for calling flyout.close() to close the flyout; | ||
*/ | ||
onClose?: (flyout: OverlayRef) => void; | ||
} | ||
|
||
interface StartDeps { | ||
|
@@ -118,9 +124,17 @@ export class FlyoutService { | |
|
||
this.activeFlyout = flyout; | ||
|
||
const onCloseFlyout = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mshustov I've made another changes to the file in this commit. I needed to be able to have a custom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or onClose = {(flyout) => if (condition) { flyout.close() } } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I'd prefer to stick to EUI |
||
if (options.onClose) { | ||
options.onClose(flyout); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mshustov I've made the change as you suggested |
||
} else { | ||
flyout.close(); | ||
} | ||
}; | ||
|
||
render( | ||
<i18n.Context> | ||
<EuiFlyout {...options} onClose={() => flyout.close()}> | ||
<EuiFlyout {...options} onClose={onCloseFlyout}> | ||
<MountWrapper mount={mount} className="kbnOverlayMountWrapper" /> | ||
</EuiFlyout> | ||
</i18n.Context>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
id: formLibCoreUseFormIsModified | ||
slug: /form-lib/core/use-form-is-modified | ||
title: useFormIsModified() | ||
summary: Know when your form has been modified by the user | ||
tags: ['forms', 'kibana', 'dev'] | ||
date: 2021-06-15 | ||
--- | ||
|
||
**Returns:** `boolean` | ||
|
||
There might be cases where you need to know if the form has been modified by the user. For example: the user is about to leave the form after making some changes, you might want to show a modal indicating that the changes will be lost. | ||
|
||
For that you can use the `useFormIsModified` hook which will update each time any of the field value changes. If the user makes a change and then undoes the change and puts the initial value back, the form **won't be marked** as modified. | ||
|
||
**Important:** If you form dynamically adds and removes fields, the `isModified` state will be set to `true` when a field is removed from the DOM **only** if it was declared in the form initial `defaultValue` object. | ||
|
||
## Options | ||
|
||
### form | ||
|
||
**Type:** `FormHook` | ||
|
||
The form hook object. It is only required to provide the form hook object in your **root form component**. | ||
|
||
```js | ||
const RootFormComponent = () => { | ||
// root form component, where the form object is declared | ||
const { form } = useForm(); | ||
const isModified = useFormIsModified({ form }); | ||
|
||
return ( | ||
<Form form={form}> | ||
<ChildComponent /> | ||
</Form> | ||
); | ||
}; | ||
|
||
const ChildComponent = () => { | ||
const isModified = useFormIsModified(); // no need to provide the form object | ||
return ( | ||
<div>...</div> | ||
); | ||
}; | ||
``` | ||
|
||
### discard | ||
|
||
**Type:** `string[]` | ||
|
||
If there are certain fields that you want to discard when checking if the form has been modified you can provide an array of field paths to the `discard` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a comment that
flyout.close
must be called by an external component?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍