svelte-material-ui icon indicating copy to clipboard operation
svelte-material-ui copied to clipboard

<Select> on:change does not work

Open risalfajar opened this issue 4 years ago • 4 comments

Describe the bug on:change never called when new value is selected

To Reproduce

<Select variant='outlined' bind:value={editedUser.currentProject} on:change={() => console.log('change called')} label='Proyek'>
    <Option value='name 1'>name 1</Option>
    <Option value='name 2'>name 2</Option>
 </Select>

Expected behavior on:change triggered and console.log() should be called

Desktop (please complete the following information):

  • OS: Pop OS! 21.04
  • Browser Brave
  • Version 1.30.89 Chromium: 94.0.4606.81 (Official Build) (64-bit)

risalfajar avatar Oct 23 '21 07:10 risalfajar

Use on:MDCSelect:change instead on:change, and it will work. https://github.com/material-components/material-components-web/tree/v11.0.0/packages/mdc-select#events

rururux avatar Oct 26 '21 17:10 rururux

Yes, the Select component doesn't actually use a native input element, so it doesn't fire a change event.

hperrin avatar Nov 01 '21 22:11 hperrin

I'll leave this open to track properly documenting this.

hperrin avatar Nov 01 '21 22:11 hperrin

Please make it work the same as native HTML <select> with Svelte. Most of us read docs only when something does not work. Making it work with on:change would save time each time the feature is needed by any developer.

peterjungx avatar Nov 18 '21 09:11 peterjungx