Repository navigation
Conversation
| import { defineCustomElement as defineIonToolbar } from '@ionic/core/components/ion-toolbar.js'; | ||
| import { defineCustomElement as defineIonVirtualScroll } from '@ionic/core/components/ion-virtual-scroll.js'; | ||
|
|
||
| const excludeValueProp = (_: any, props: any) => { |
There was a problem hiding this comment.
This file is unfortunately autogenerated, so any changes here will be overwritten every time the core package is built.
Instead, we will need to exclude ion-select from being auto generated here: https://github.com/ionic-team/ionic-framework/blob/main/core/stencil.config.ts#L72
and then create a new file in packages/react/src/components/ called IonSelect.tsx that is basically:
import type { JSX } from '@ionic/core/components';
import { defineCustomElement } from '@ionic/core/components/ion-select.js';
import { createReactComponent } from './react-component-lib';
const excludeValueProp = (_: any, props: any) => {
const newProps = {
...props
};
delete newProps['value'];
return newProps;
}
export const IonSelect = /*@__PURE__*/createReactComponent<JSX.IonSelect, HTMLIonSelectElement>('ion-select', undefined, excludeValueProp, defineCustomElement);and finally export it from packages/react/src/components/index.ts.
There was a problem hiding this comment.
@sean-perkins before I make the changes, does this approach to fixing the issue seem to be correct?
I set some breakpoints to try and further validate my changes and I believe this is correct. By providing the custom mutator you prevent the value prop from being passed to React.createElement. If it is passed the value value will be reflected to the attribute and stringified. The value value will still be updated by the componentDidUpdate lifecycle hook.
The issue seems to be pretty severe / high priority because I believe the use case of IonSelect[multiple] as a controlled component is broken in Ionic v6 (react).
It's worth noting this change may not be needed / could be reverted if full support for Web Components lands in React 18 which seems like it may be a possibility as full support is currently on the React experimental branch.
There was a problem hiding this comment.
Since React reflects props to attributes does it make sense for the render function to filter out any prop with an object value to avoid this potential kind of issue elsewhere?
|
@sean-perkins anymore thoughts on my responses? |
|
Thanks for the PR and apologies for the delay. We appreciate all the hard work you put into creating this PR. We have an update coming in Ionic 7.0 that changes how #24584 is resolved by these changes. As a result, we are going to close this PR in favor of the changes coming in Ionic 7.0 We expect these changes to provide a more stable and consistent experience for Ionic developers. I have followed up on the issue in #24584 (comment) and have provided a dev build with these Ionic 7.0 changes for testing. Let me know if you have any questions! |
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build) was run locally and any changes were pushednpm run lint) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
When using multiple and passing an array of objects ionChange is emitted multiple times. The array is eventually stringified and the component becomes unusable.
Issue Number: #24584
What is the new behavior?
The array is not stringified and the component behaves as expected.
Does this introduce a breaking change?
Other information