Skip to content

Approach to prevent a tab change (sl-tab-group) #1970

Answered by blendtwenty
blendtwenty asked this question in Help
Discussion options

You must be logged in to vote

Yippee. Achieved. Very straight forward and embarrassed I didn't consider it before posting my question. Doh.

  1. Add a handler to the sl-tab click event; and
  2. event.stopPropagation();
class PromptingTabPanel extends LitElement {
  render() {
    return html`
      <sl-tab-group>
        <sl-tab slot="nav" @click=${this.handleClick} panel="about">About</sl-tab>
        <sl-tab slot="nav" panel="editor">Editor</sl-tab>

        <sl-tab-panel name="about">This is the about tab panel.</sl-tab-panel>
        <sl-tab-panel name="editor">This is the editor tab panel.</sl-tab-panel>
      </sl-tab-group>
    `;
  }
  handleClick(event) {
    event.stopPropagation();
    if (window.confirm("Do you r…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by blendtwenty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant