Skip to content

Commit fc4650f

Browse files
committed
fix #348
1 parent 5952743 commit fc4650f

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

exampleVault/Buttons/Button Example.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Meta Bind is getting Buttons
1010
text `BUTTON[docs-button]` text
1111
text `BUTTON[docs-button, docs, open-button]` text
1212

13+
```meta-bind
14+
BUTTON[docs-button]
15+
```
16+
17+
asase
18+
1319
```meta-bind-button
1420
style: primary
1521
label: Open Meta Bind FAQ

exampleVault/Input Fields/List.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ list4:
1818
list5:
1919
- "[[Other/Example Notes/Example Note with Embeds.md|Example Note with Embeds]]"
2020
- "[[Other/Example Notes/Example Note with Callouts.md|Example Note with Callouts]]"
21-
list6: null
21+
list6:
2222
---
2323

2424
### List

packages/core/src/fields/button/ButtonField.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class ButtonField extends Mountable {
1212
inline: boolean;
1313
position: NotePosition | undefined;
1414
buttonComponent?: ButtonComponent;
15+
isInGroup: boolean;
1516
isPreview: boolean;
1617

1718
constructor(
@@ -20,6 +21,7 @@ export class ButtonField extends Mountable {
2021
filePath: string,
2122
renderChildType: RenderChildType,
2223
position: NotePosition | undefined,
24+
isInGroup: boolean,
2325
isPreview: boolean,
2426
) {
2527
super();
@@ -29,6 +31,7 @@ export class ButtonField extends Mountable {
2931
this.filePath = filePath;
3032
this.inline = renderChildType === RenderChildType.INLINE;
3133
this.position = position;
34+
this.isInGroup = isInGroup;
3235
this.isPreview = isPreview;
3336
}
3437

@@ -37,7 +40,7 @@ export class ButtonField extends Mountable {
3740
DomHelpers.removeAllClasses(targetEl);
3841
DomHelpers.addClasses(targetEl, ['mb-button', this.inline ? 'mb-button-inline' : 'mb-button-block']);
3942

40-
if (!this.inline && !this.isPreview) {
43+
if (!this.inline && !this.isPreview && !this.isInGroup) {
4144
if (this.config.id) {
4245
this.plugin.api.buttonManager.addButton(this.filePath, this.config);
4346
}

packages/core/src/fields/button/ButtonGroupField.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,22 @@ export class ButtonGroupField extends Mountable {
5959
for (const buttonId of this.referencedIds) {
6060
const wrapperEl = DomHelpers.createElement(targetEl, 'span');
6161

62-
const initialButton: ButtonComponent | undefined = this.renderInitialButton(wrapperEl, buttonId);
62+
let initialButton: ButtonComponent | undefined = this.renderInitialButton(wrapperEl, buttonId);
6363
let button: ButtonField | undefined;
6464

6565
const loadListenerCleanup = this.plugin.api.buttonManager.registerButtonLoadListener(
6666
this.filePath,
6767
buttonId,
6868
(buttonConfig: ButtonConfig) => {
6969
initialButton?.$destroy();
70+
initialButton = undefined;
7071
button = new ButtonField(
7172
this.plugin,
7273
buttonConfig,
7374
this.filePath,
7475
this.renderChildType,
7576
this.notePosition,
77+
true,
7678
false,
7779
);
7880
button.mount(wrapperEl);
@@ -81,6 +83,7 @@ export class ButtonGroupField extends Mountable {
8183

8284
this.registerUnmountCb(() => {
8385
initialButton?.$destroy();
86+
initialButton = undefined;
8487
button?.unmount();
8588
loadListenerCleanup();
8689
});

packages/core/src/fields/button/ButtonMountable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class ButtonMountable extends FieldMountable {
5555
this.getFilePath(),
5656
RenderChildType.BLOCK,
5757
this.position,
58+
false,
5859
this.isPreview,
5960
);
6061
this.buttonField.mount(targetEl);

packages/core/src/modals/modalContents/buttonBuilder/ButtonBuilderModalComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
buttonMountable?.unmount();
4646
if (el) {
4747
DomHelpers.empty(el);
48-
buttonMountable = new ButtonField(plugin, config, '', RenderChildType.BLOCK, undefined, true);
48+
buttonMountable = new ButtonField(plugin, config, '', RenderChildType.BLOCK, undefined, false, true);
4949
buttonMountable.mount(el);
5050
}
5151
}

0 commit comments

Comments
 (0)