Skip to content

Commit

Permalink
Merge pull request #1658 from Infineon/1657-single-select-react-compo…
Browse files Browse the repository at this point in the history
…nent-re-rendering-twice-on-option-change

Single-select: clears the field only on options update (prevents double re-rendering of component)
  • Loading branch information
tishoyanchev authored Dec 17, 2024
2 parents 4a02d3b + 07f5538 commit f816611
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 62 deletions.
2 changes: 1 addition & 1 deletion examples/wrapper-components/react-vite-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-react": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"@infineon/infineon-design-system-react": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"path": "^0.12.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper-components/vue-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:local": "run-p preview:link watch:library"
},
"dependencies": {
"@infineon/infineon-design-system-vue": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"@infineon/infineon-design-system-vue": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^4.0.0",
"vite": "^5.0.12",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"command": {
"publish": {
"verifyAccess": false
Expand Down
58 changes: 9 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/components-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "components-angular",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -26,7 +26,7 @@
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@infineon/infineon-design-system-angular": "^30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"@infineon/infineon-design-system-angular": "^30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typescript": "~5.4.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-angular",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"description": "Infineon design system Stencil web components for Angular",
"author": "Verena Lechner",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"@angular/common": "^18.0.0",
"@angular/core": "^18.0.0",
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0"
"@infineon/infineon-design-system-stencil": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0"
},
"dependencies": {
"tslib": "^2.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/components-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-react",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"description": "Infineon design system Stencil web components for React",
"main": "./dist/index.js",
"types": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"@infineon/infineon-design-system-stencil": "^30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"@stencil/react-output-target": "^0.7.1"
},
"auto": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-vue",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"description": "Infineon design system Stencil web components for Vue",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@infineon/design-system-tokens": "3.3.4",
"@infineon/infineon-design-system-stencil": "^30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0"
"@infineon/infineon-design-system-stencil": "^30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0"
},
"auto": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@infineon/infineon-design-system-stencil",
"version": "30.7.0--canary.1659.03a8f843402df515bf8c98507d939beebe4dad26.0",
"version": "30.8.0--canary.1658.0b51dae92afc81a0703a9603d6672557cc1387af.0",
"private": false,
"description": "Infineon design system Stencil web components",
"homepage": "https://infineon.github.io/infineon-design-system-stencil",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class Choices implements IChoicesProps, IChoicesMethods {
@State() optionIsSelected: boolean = false;

private resizeObserver: ResizeObserver;
private previousOptions: any[] = [];

@Element() private readonly root: HTMLElement;
private choice;
Expand Down Expand Up @@ -292,9 +293,16 @@ export class Choices implements IChoicesProps, IChoicesMethods {

protected componentWillUpdate() {
this.handleCloseButton()
this.clearSelectField()
this.previousOptions = [...this.options];
const optionsAreEqual = this.isEqual(this.options, this.previousOptions);
if (this.options && !optionsAreEqual) {
this.clearSelectField();
}
}

isEqual(a: any, b: any[]) {
return JSON.stringify(a) === JSON.stringify(b);
}


addResizeObserver() {
Expand Down

0 comments on commit f816611

Please sign in to comment.