question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Menu bar buttons don't get their active state properly

See original GitHub issue

Describe the bug We created a component which embeds the tiptap editor, something like:

<template>
    <div>
        <form method="post" class="form-grid">
                <div class="row">
                    <div class="col-12 col-md-12 col-lg-12">
                        <div class="form-group">
                            <label>Editor</label>
                            <div class="sg-editor">
                                <editor-menu-bar :editor="descriptionEditor" v-slot="{ commands, isActive }">
                                    <div class="sg-editor-menubar">
                                        <a
                                                href="javascript:;"
                                                :class="{ 'sg-btn-bold ': true, 'is-active': isActive.bold() }"
                                                @click.prevent="commands.bold">
                                            <i class="fas fa-bold"></i>
                                        </a>

                                        <a
                                                href="javascript:;"
                                                :class="{ 'sg-btn-italic': true, 'is-active': isActive.italic() }"
                                                @click="commands.italic">
                                            <i class="fas fa-italic"></i>
                                        </a>
                                    </div>
                                </editor-menu-bar>
                                <editor-content
                                        :class="{ 'sg-editor-area': true}"
                                        :editor="descriptionEditor" />
                            </div>
                        </div>
                        <div class="spacer"></div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</template>

<script lang="ts">
    import Vue from "vue";
    import { Editor, EditorContent, EditorMenuBar } from "tiptap"
    import { Bold, Italic } from "tiptap-extensions"
    export default Vue.extend({
        props: {},
        data() {
            return <{
                descriptionEditor?: Editor;
            }>{
            }
        },
        components: {
            EditorContent,
            EditorMenuBar,
        },
        created(): void {
            this.descriptionEditor = new Editor({
                extensions: [
                    new Bold(),
                    new Italic(),
                ],
                onFocus: () => {},
                onUpdate: (state) => {
                    this.fields.description = state.getHTML();
                    if (this.fields.description === "<p></p>") {
                        this.fields.description = "";
                    }
                },
                content: ""
            });
        },
        beforeDestroy(): void {
            this.descriptionEditor.destroy();
        },
        methods: {},
        computed: {},
    });
</script>

<style lang="scss" scoped>

</style>

And we’re observing a weird behavior.
When we select text from the editor and then press the bold button for instance, the text is transformed in bold, as expected, but the bold button isn’t getting it’s active class.
Then, if we click anywhere outside the editor, then the button will get it’s active class. If we then click on an already bolded text, we expect the button to get the active class, instead it does not, but it does when we click outside the editor. Se below video which shows this behavior.

Steps to Reproduce / Codesandbox Example We simply followed the examples from the examples page.

Expected behavior We expect for the buttons to get the correct active class name when they are pressed or when a text is selected that matches the button functionality.

Screenshots Here’s a short video: https://www.dropbox.com/s/okzxiqkzuzl80da/vuejs-editor-bug.mov?dl=0

Environment

  • OS: MacOS
  • Browser chrome
  • Version 81.0.4044.138 (Official Build) (64-bit)
  • Mobile / Desktop: Desktop

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vincentdesmarescommented, Sep 13, 2021

@philippkuehn Sure! We will try that this week.

1reaction
madebycalipercommented, Oct 16, 2020

I’m having the same issue. There’s a workaround presented by someone in another duplicate thread that I can confirm works. Just replace editor-menu-bar with editor-menu-bubble and it should work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap navbar Active State not working - Stack Overflow
I use the class="active" on my navbar and it does not switch when I press menu items. I know how to do this...
Read more >
Windows 10 Taskbar Not Working? 8 Common Issues and Fixes
Is your Windows 10 taskbar not working properly? Here are fixes for common issues, like the taskbar freezing or not auto-hiding.
Read more >
Task Manager Menu Bar and Tabs Are Not Visible
Click Start, and then click Run. Type taskmgr.exe. Hold down CTRL+ALT+SHIFT at the same time, and while holding them down press ENTER.
Read more >
SOLVED: Navigationbar- / Toolbar Button not working properly
Hi,. I noticed that Navigationbar- / Toolbar Buttons are not working properly when there is at least one @State variable refreshing the View ......
Read more >
The menu bar - Components - Human Interface Guidelines
Provide a Window menu even if your app has only one window. Include the Minimize and Zoom menu items so people using Full...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found