Skip to content

Edit multiple elements - previous actions are assign to last  #4

Closed
@marczuk

Description

@marczuk

Describe the bug

I have few texts to edit on one page. When I'm trying to edit few of them at once. And click on appeared buttons, doesn't matter on which button I click, they will execute only on last one expanded.

Steps to reproduce

My malle setup:

// now create the malle
const malle = new Malle({
  debug: true,
  formClasses: ['d-flex'],
  cancel: 'Cancel',
  cancelClasses: ['btn', 'btn-danger', 'btn-sm'],
  inputClasses: ['form-control', 'd-inline'],
  submit: 'OK',
  submitClasses: [ 'btn', 'btn-primary', 'mx-2', 'btn-sm'],
  tooltip: 'Click this to edit',
  onBlur: Action.Ignore,
  onEnter: Action.Ignore,
  // this is the function that will be called once user has finished entering text (press Enter or click outside)
  // it receives the new value, the original element, the event and the input element
  fun: (value, original, event, input) => {
    let fieldName = original.getAttribute('id')
    return myCustomFunction(value, fieldName);
  },
}).listen(); // directly start listening after object creation

and later in html:

<label for="testName" class="form-label">Name</label>
<span type="text" id="testName" data-malleable='true' class="form-control">{{ test['testName'] }}</span>

<br />
<label for="testBranch" class="form-label">Branch</label>
<span type="text" id="testBranch" data-malleable='true' class="form-control">{{ test['testBranch'] }}</span>

Information

  • malle version: latest 2.2.0 "@deltablot/malle": "^2.2.0"
  • Client operating system (e.g: MacOS, Windows, GNU+Linux): MacOS
  • Browser (e.g. firefox, chrome): Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions