From f0312469e454757b735818a5588af26f82a8ff18 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:45:14 +0200 Subject: [PATCH] chore: version packages (#1568) Co-authored-by: eikeland --- .changeset/cyan-items-provide.md | 94 ------------------------------ packages/person/CHANGELOG.md | 98 ++++++++++++++++++++++++++++++++ packages/person/package.json | 2 +- 3 files changed, 99 insertions(+), 95 deletions(-) delete mode 100644 .changeset/cyan-items-provide.md diff --git a/.changeset/cyan-items-provide.md b/.changeset/cyan-items-provide.md deleted file mode 100644 index 3d8320b46..000000000 --- a/.changeset/cyan-items-provide.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -'@equinor/fusion-wc-person': patch ---- - -Fixes clearing person when using the `selectedPerson` property - -# Summary of Latest Changes in This Branch Compared to Main Branch - -## File: `controller.ts` - -### Lines: 199-264 - -### Summary of Changes: - -1. **New Methods Added:** - - **`clearInput()`**: Clears the input fields and resets the host's value and search properties. - - **`clear()`**: Calls `clearInput()`, clears selected IDs, resets the selected person, and dispatches a custom `PersonSelectEvent`. - - **`closeClick(e: MouseEvent | KeyboardEvent)`**: Handles the close icon click event, blurs the input and close icon, closes the dropdown if open, and calls an external close handler if defined. - -### Detailed Changes: - -1. **Method: `clearInput()`** - - **Purpose:** Clears the input fields and resets the host's value and search properties. - - **Code:** - ```typescript - public clearInput() { - this.#host.value = ''; - this.#host.search = ''; - this.#host.textInputElement.value = ''; - } - ``` - -2. **Method: `clear()`** - - **Purpose:** Calls `clearInput()`, clears selected IDs, resets the selected person, and dispatches a custom `PersonSelectEvent`. - - **Code:** - ```typescript - public clear() { - this.clearInput(); - - if (this.selectedIds.size) { - this.selectedIds.clear(); - } - - if (this.#host.selectedPerson) { - this.#host.selectedPerson = null; - } - - /* Dispatch custom select event with our details */ - this.#host.dispatchEvent( - new PersonSelectEvent({ - detail: { - selected: null, - }, - bubbles: true, - }), - ); - } - ``` - -3. **Method: `closeClick(e: MouseEvent | KeyboardEvent)`** - - **Purpose:** Handles the close icon click event, blurs the input and close icon, closes the dropdown if open, and calls an external close handler if defined. - - **Code:** - ```typescript - public closeClick = (e: MouseEvent | KeyboardEvent): void => { - if (e.type === 'keydown') { - - /* only close on enter or space not tab */ - const me = e as KeyboardEvent; - if (me.key !== 'Enter' && me.key !== 'Space') { - return; - } - - /* blur closeicon if focused */ - const closeIcon = this.#host.renderRoot.querySelector('.trailing'); - if (closeIcon) { - (closeIcon as HTMLSpanElement).blur(); - } - } - - if (this.#host.textInputElement) { - this.#host.textInputElement.blur(); - } - - /* close dropdown if open */ - if (this.isOpen) { - this.isOpen = false; - } - - /* call resolvers handleclick if defined */ - if (this.#externaCloseHandler) { - this.#externaCloseHandler(e); - } - } - ``` \ No newline at end of file diff --git a/packages/person/CHANGELOG.md b/packages/person/CHANGELOG.md index b6e598981..243075578 100644 --- a/packages/person/CHANGELOG.md +++ b/packages/person/CHANGELOG.md @@ -1,5 +1,103 @@ # Change Log +## 3.0.1 + +### Patch Changes + +- [#1566](https://github.com/equinor/fusion-web-components/pull/1566) [`5b61628`](https://github.com/equinor/fusion-web-components/commit/5b616282a4c74c191352ee42d356c72443961e3d) Thanks [@eikeland](https://github.com/eikeland)! - Fixes clearing person when using the `selectedPerson` property + + # Summary of Latest Changes in This Branch Compared to Main Branch + + ## File: `controller.ts` + + ### Lines: 199-264 + + ### Summary of Changes: + + 1. **New Methods Added:** + - **`clearInput()`**: Clears the input fields and resets the host's value and search properties. + - **`clear()`**: Calls `clearInput()`, clears selected IDs, resets the selected person, and dispatches a custom `PersonSelectEvent`. + - **`closeClick(e: MouseEvent | KeyboardEvent)`**: Handles the close icon click event, blurs the input and close icon, closes the dropdown if open, and calls an external close handler if defined. + + ### Detailed Changes: + + 1. **Method: `clearInput()`** + - **Purpose:** Clears the input fields and resets the host's value and search properties. + - **Code:** + ```typescript + public clearInput() { + this.#host.value = ''; + this.#host.search = ''; + this.#host.textInputElement.value = ''; + } + ``` + 2. **Method: `clear()`** + + - **Purpose:** Calls `clearInput()`, clears selected IDs, resets the selected person, and dispatches a custom `PersonSelectEvent`. + - **Code:** + + ```typescript + public clear() { + this.clearInput(); + + if (this.selectedIds.size) { + this.selectedIds.clear(); + } + + if (this.#host.selectedPerson) { + this.#host.selectedPerson = null; + } + + /* Dispatch custom select event with our details */ + this.#host.dispatchEvent( + new PersonSelectEvent({ + detail: { + selected: null, + }, + bubbles: true, + }), + ); + } + ``` + + 3. **Method: `closeClick(e: MouseEvent | KeyboardEvent)`** + + - **Purpose:** Handles the close icon click event, blurs the input and close icon, closes the dropdown if open, and calls an external close handler if defined. + - **Code:** + + ```typescript + public closeClick = (e: MouseEvent | KeyboardEvent): void => { + if (e.type === 'keydown') { + + /* only close on enter or space not tab */ + const me = e as KeyboardEvent; + if (me.key !== 'Enter' && me.key !== 'Space') { + return; + } + + /* blur closeicon if focused */ + const closeIcon = this.#host.renderRoot.querySelector('.trailing'); + if (closeIcon) { + (closeIcon as HTMLSpanElement).blur(); + } + } + + if (this.#host.textInputElement) { + this.#host.textInputElement.blur(); + } + + /* close dropdown if open */ + if (this.isOpen) { + this.isOpen = false; + } + + /* call resolvers handleclick if defined */ + if (this.#externaCloseHandler) { + this.#externaCloseHandler(e); + } + } + ``` + ## 3.0.0 ### Major Changes diff --git a/packages/person/package.json b/packages/person/package.json index d0d054109..e0454c4a9 100644 --- a/packages/person/package.json +++ b/packages/person/package.json @@ -1,6 +1,6 @@ { "name": "@equinor/fusion-wc-person", - "version": "3.0.0", + "version": "3.0.1", "description": "", "main": "lib/index.js", "exports": {