Skip to content

Fix mx-step WC "Step +1" counter not incrementing in section 6.a - #151

Draft
dadhi with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-wc-step-plus-one
Draft

Fix mx-step WC "Step +1" counter not incrementing in section 6.a#151
dadhi with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-wc-step-plus-one

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The mx-step Web Component dispatched step-picked with this._value + 1 on every click but never mutated this._value, so every click emitted step: 1 and the counter appeared frozen.

Changes

  • mx-step onclick — increment this._value in-place and update the shadow <output> before dispatching, so consecutive clicks accumulate:

    // Before
    () => this.dispatchEvent(new CustomEvent('step-picked', { detail: { step: this._value + 1 } }))
    
    // After
    () => {
      this._value += 1;
      this.shadowRoot.querySelector('output').textContent = '' + this._value;
      this.dispatchEvent(new CustomEvent('step-picked', { detail: { step: this._value } }));
    }
  • mx-step element binding — added data-m-ex:wc-step@wc-picked="'' + val" to close the feedback loop: when the wc-picked store updates from the custom event, wc-step is also updated, keeping the "WC default value prop" <span> in sync.

Copilot AI linked an issue Aug 4, 2026 that may be closed by this pull request
Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix the wc 'Step +1' functionality in index.html notebook Fix mx-step WC "Step +1" counter not incrementing in section 6.a Aug 4, 2026
Copilot AI requested a review from dadhi August 4, 2026 22:06
Comment thread index.html Outdated
set value(v) { this._value = +v || 0; this.shadowRoot.querySelector('output').textContent = '' + this._value }
connectedCallback() {
this.shadowRoot.querySelector('button').onclick = () => this.dispatchEvent(new CustomEvent('step-picked', { detail: { step: this._value + 1 } }))
this.shadowRoot.querySelector('button').onclick = () => { this._value += 1; this.shadowRoot.querySelector('output').textContent = '' + this._value; this.dispatchEvent(new CustomEvent('step-picked', { detail: { step: this._value } })) }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this code? Can we use the dmax for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. The manual _value mutation and textContent update are now replaced with a call to this.value = this._value + 1, which reuses the existing value setter that already handles both. The dmax binding data-m-ex:.@wc-step will also drive the setter when the wc-step store updates (via the wc-picked feedback binding), keeping everything in sync.

Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot AI requested a review from dadhi August 5, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix the wc 'Step +1' in the index.html notebook

2 participants