Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Bip Bop - Fusion Web Components Release #1568

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

github-actions[bot]
Copy link
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@equinor/[email protected]

Patch Changes

  • #1566 5b61628 Thanks @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:
        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:

        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:

        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);
          }
        }

@eikeland eikeland merged commit f031246 into main Aug 12, 2024
@eikeland eikeland deleted the changeset-release/main branch August 12, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant