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

fix(alert): pause auto-close alert when link focused #9503

Merged
merged 11 commits into from
Jun 5, 2024

Conversation

josercarcamo
Copy link
Contributor

Related Issue: #5960

Summary

Paused auto close when the focus is in the link or close buton or when the mouse is hovered over the alert dialog.

@josercarcamo josercarcamo requested a review from a team as a code owner June 3, 2024 23:45
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Jun 3, 2024
Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @josercarcamo. I'm not super familiar with the alert component so maybe someone who is can review this a bit better :)

window.clearTimeout(this.autoCloseTimeoutId);
this.totalOpenTime = Date.now() - this.initialOpenTime;
this.lastMouseOverBegin = Date.now();
};

private handleMouseLeave = (): void => {
private handleUnfocus = (): void => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to handleBlur? focus/blur and focusin/focusout are the correct opposites I think

packages/calcite-components/src/components/alert/alert.tsx Outdated Show resolved Hide resolved
@@ -296,6 +296,13 @@ $alertDurations:
:host(:hover[auto-close-duration="#{$name}"]) .dismiss-progress:after {
animation-play-state: paused;
}
:host(:focus[auto-close-duration="#{$name}"]) .dismiss-progress:after {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can be combined like this:

:host(:hover[auto-close-duration="#{$name}"]) .dismiss-progress:after,
:host(:focus[auto-close-duration="#{$name}"]) .dismiss-progress:after {
    animation-play-state: paused;
  }

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good after adding class to CSS lookup object.

@@ -226,13 +227,18 @@ export class Alert implements OpenCloseComponent, LoadableComponent, T9nComponen
[CSS.containerQueued]: queued,
[`${CSS.container}--${placement}`]: true,
[CSS.containerSlottedInShell]: this.slottedInShell,
["focused"]: this.keyBoardFocus,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josercarcamo can you add the focused class to the CSS object?

@josercarcamo josercarcamo added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Jun 5, 2024
@josercarcamo josercarcamo merged commit fa9a829 into main Jun 5, 2024
12 checks passed
@josercarcamo josercarcamo deleted the josercarcamo/5960-timer-pause-when-focus branch June 5, 2024 23:18
@github-actions github-actions bot added this to the 2024-06-25 - Jun Release milestone Jun 5, 2024
benelan added a commit that referenced this pull request Jun 10, 2024
…orkflow

* origin/main: (26 commits)
  revert: refactor: add simpler `componentFocusable` util (deprecates `LoadableComponent`) (#9515)
  chore(linting): enable selector-pseudo-element-colon-notation rule (#9518)
  refactor(storybook): refactor tooltip simple story interface (#9538)
  refactor(dom): consolidate transition/animation waiting utils (#9341)
  refactor(storybook): build storybook simple story args interfaces using component class (#9457)
  chore: release next
  fix(block): add accessible label for slotted controls (#9502)
  feat(action-bar, action-pad): add expandLabel and collapseLabel to messages (#9497)
  chore: release next
  feat(action-menu, combobox, dropdown, input-date-picker, popover): allow logical placements for flipPlacements property. #8825 (#9490)
  fix(popover): correct border radius on close button (#9485)
  fix(list-item): hide nested list items by default (#9474)
  refactor: move component types into component specific interfaces files (#9527)
  chore: release next
  fix(alert): pause auto-close alert when link focused (#9503)
  refactor(storybook): consolidate storybook and component types (#9500)
  refactor(calcite-block-section,calcite-card): consolidate interfaces imports (#9517)
  chore: release next
  fix(block-section): restore block toggling when clicking on the header switch (#9472)
  chore: release next
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants