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(carousel): Prevent duplicate animation when navigating via keyboard #9848

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

macandcheese
Copy link
Contributor

Related Issue: #9471

Summary

When using home and end while focused on the Container, prevent "re-navigating" to the currently active Carousel Item and showing a duplicate animation. This matches the behavior when a user selects an individual Carousel Item "dot", both with mouse or via keyboard.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Jul 24, 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.

comment!

@@ -512,13 +514,19 @@ export class Carousel
break;
case "Home":
event.preventDefault();
if (this.selectedIndex === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

should this move before event.preventDefault so event isn't prevented if nothing happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'd still expect it to be prevented. Without it, the Home / End keys could navigate the Carousel with one keystroke and then unexpectedly scroll the page with the next.

Copy link
Member

Choose a reason for hiding this comment

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

Yep. makes sense.

this.direction = "backward";
this.setSelectedItem(0, true);
break;
case "End":
event.preventDefault();
if (this.selectedIndex === lastItem) {
Copy link
Member

Choose a reason for hiding this comment

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

should this move before event.preventDefault so event isn't prevented if nothing happens?

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.

👍

@@ -512,13 +514,19 @@ export class Carousel
break;
case "Home":
event.preventDefault();
if (this.selectedIndex === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Yep. makes sense.

@macandcheese macandcheese added the skip visual snapshots Pull requests that do not need visual regression testing. label Jul 25, 2024
@macandcheese macandcheese merged commit 37229a5 into dev Jul 25, 2024
11 checks passed
@macandcheese macandcheese deleted the macandcheese/9471-carousel-keyboard-animation branch July 25, 2024 17:33
@github-actions github-actions bot added this to the 2024-07-30 - Jul Release milestone Jul 25, 2024
benelan added a commit that referenced this pull request Jul 25, 2024
…-to-monorepo

* origin/dev:
  ci: add type checking to github scripts (#9851)
  chore: release next
  fix(carousel): Prevent duplicate animation when navigating via keyboard (#9848)
  chore: release next
  fix(tabs): Update tab title indicator display (#9666)
calcite-admin pushed a commit that referenced this pull request Jul 30, 2024
…rd (#9848)

**Related Issue:** #9471

## Summary
When using `home` and `end` while focused on the Container, prevent
"re-navigating" to the currently active Carousel Item and showing a
duplicate animation. This matches the behavior when a user selects an
individual Carousel Item "dot", both with mouse or via keyboard.
benelan pushed a commit that referenced this pull request Jul 31, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>@esri/calcite-ui-icons: 3.30.0</summary>

##
[3.30.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-ui-icons-v3.29.0...@esri/calcite-ui-icons@3.30.0)
(2024-07-31)


### Miscellaneous Chores

* Add calcite-ui-icons to monorepo
([#9835](#9835))
([05264ea](05264ea))
</details>

<details><summary>@esri/calcite-components: 2.11.0</summary>

##
[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components@2.10.1...@esri/calcite-components@2.11.0)
(2024-07-31)


### Features

* **chip:** Enhance multi-select group affordance
([#9286](#9286))
([fd150e1](fd150e1))
* **color-picker, color-picker-hex-input:** Add input auto commit, blur
and auto select enhancements.
([#9701](#9701))
([b2be625](b2be625))
* **combobox-item:** Apply heading color according to updated spec
([#9883](#9883))
([9f642ff](9f642ff))
* **combobox, combobox-item:** Add `description`, `shortHeading` props
and `content-end` slot
([#9771](#9771))
([78eb555](78eb555))
* **combobox, combobox-item:** Add `metadata` support for filtering
([#9819](#9819))
([5de7787](5de7787))
* **combobox:** Append custom values to top of dropdown
([#9817](#9817))
([bd55097](bd55097))
* **dialog:** Add padding to default slot
([#9871](#9871))
([9d89d1d](9d89d1d))
* **dialog:** Adds new dialog component and deprecates the modal
component
([#9751](#9751))
([0111c23](0111c23))
* **icon:** Type icon names
([#9650](#9650))
([7513f3a](7513f3a))
* **panel, flow-item:** Add alerts slot
([#9778](#9778))
([8b9b820](8b9b820))
* **panel, flow-item:** Add beforeClose property
([#9770](#9770))
([aefd3cb](aefd3cb))
* **panel, flow-item:** Add scale property
([#9730](#9730))
([27c597e](27c597e))
* Provide info message on stamped version instead of warning
([#9739](#9739))
([b25cb7b](b25cb7b))
* **shell-panel:** Deprecate float displayMode and add float-content and
float-all
([#9795](#9795))
([bf93728](bf93728))
* **tooltip:** Support touch events
([#9487](#9487))
([633706b](633706b))


### Bug Fixes

* **block-section:** Apply missing CSS class to start/end icon
([#9688](#9688))
([2169ed2](2169ed2))
* **block:** Remove top padding when no heading is defined
([#9782](#9782))
([704f5df](704f5df))
* **carousel:** Prevent duplicate animation when navigating via keyboard
([#9848](#9848))
([cfdbd44](cfdbd44))
* **combobox-item:** Tweak center content font-weight and spacing
([#9818](#9818))
([a67c4af](a67c4af))
* **deps:** Move @types/sortablejs as a dependency so the public types
resolve properly
([#9786](#9786))
([3d47c52](3d47c52))
* **dialog:** Fix menu positioning when when overlayPositioning is
'fixed' and menuOpen is true
([#9891](#9891))
([4390177](4390177))
* Fix issue in Firefox where disabled elements were incorrectly enabled
when a sibling was enabled
([#9710](#9710))
([cd4d52c](cd4d52c))
* **flow-item:** Set closed property to true when internal panel is
closed
([#9715](#9715))
([f7d2a4f](f7d2a4f))
* Improve browser check to resolve SSR errors
([#9897](#9897))
([bdb225b](bdb225b))
* **input-date-picker:** Ensure initial value is in range
([#9894](#9894))
([7d05134](7d05134))
* **input-number:** Restore decimal input mode default
([#9741](#9741))
([1165dca](1165dca))
* **panel, flow-item:** Fix footer-padding CSS prop regression
([#9757](#9757))
([f935790](f935790))
* **panel, flow-item:** Prevent footer slots from conflicting with each
other
([#9856](#9856))
([cffaff8](cffaff8))
* **panel:** Correct footer padding and layout
([#9868](#9868))
([1e02ece](1e02ece))
* **radio-button-group:** Remove blank clickable space outside of label
([#9793](#9793))
([4cc24a0](4cc24a0))
* **segmented-control:** Make check state update correctly
([#9733](#9733))
([602c922](602c922))
* **shell:** Fix resizing a slotted shell-panel when clicking to resize
([#9846](#9846))
([326001c](326001c))
* **shell:** Update shell to correctly position calcite shell panel at
shell's bottom
([#9748](#9748))
([5959db7](5959db7))
* **tab-title:** Adjust hover styling for `bordered` Tab Title
([#9867](#9867))
([a77cd27](a77cd27))
* **tabs:** Handle tab close events that remove the associated tab-title
and tab elements from the DOM
([#9768](#9768))
([bda619c](bda619c))
* **tabs:** Update tab title indicator display
([#9666](#9666))
([5f0914b](5f0914b))
* **tile:** Center align contentTop and contentBottom slots when
alignment prop equals "center"
([#9732](#9732))
([1a8393b](1a8393b))
* **tile:** Center align slot's text when alignment is equal to center
([#9773](#9773))
([8611bfc](8611bfc))
* **time-picker:** Render meridiem first for korean locale
([#9842](#9842))
([897f924](897f924))
* **tooltip:** Allow focusing on a reference element and then clicking
on a tooltip
([#9878](#9878))
([dfca2d4](dfca2d4))
* Widen icon type to allow string
([#9915](#9915))
([44138b1](44138b1))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-ui-icons bumped from ^3.29.1-next.0 to ^3.30.0
</details>

<details><summary>@esri/calcite-components-angular: 2.11.0</summary>

##
[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-angular@2.10.1...@esri/calcite-components-angular@2.11.0)
(2024-07-31)


### Miscellaneous Chores

* **@esri/calcite-components-angular:** Synchronize components versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

<details><summary>@esri/calcite-components-react: 2.11.0</summary>

##
[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-react@2.10.1...@esri/calcite-components-react@2.11.0)
(2024-07-31)


### Miscellaneous Chores

* **@esri/calcite-components-react:** Synchronize components versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
benelan pushed a commit that referenced this pull request Jul 31, 2024
🤖 I have created a release *beep* *boop*
---

<details><summary>@esri/calcite-ui-icons: 3.30.0</summary>

[3.30.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-ui-icons-v3.29.0...@esri/calcite-ui-icons@3.30.0)
(2024-07-31)

* Add calcite-ui-icons to monorepo
([#9835](#9835))
([05264ea](05264ea))
</details>

<details><summary>@esri/calcite-components: 2.11.0</summary>

[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components@2.10.1...@esri/calcite-components@2.11.0)
(2024-07-31)

* **chip:** Enhance multi-select group affordance
([#9286](#9286))
([fd150e1](fd150e1))
* **color-picker, color-picker-hex-input:** Add input auto commit, blur
and auto select enhancements.
([#9701](#9701))
([b2be625](b2be625))
* **combobox-item:** Apply heading color according to updated spec
([#9883](#9883))
([9f642ff](9f642ff))
* **combobox, combobox-item:** Add `description`, `shortHeading` props
and `content-end` slot
([#9771](#9771))
([78eb555](78eb555))
* **combobox, combobox-item:** Add `metadata` support for filtering
([#9819](#9819))
([5de7787](5de7787))
* **combobox:** Append custom values to top of dropdown
([#9817](#9817))
([bd55097](bd55097))
* **dialog:** Add padding to default slot
([#9871](#9871))
([9d89d1d](9d89d1d))
* **dialog:** Adds new dialog component and deprecates the modal
component
([#9751](#9751))
([0111c23](0111c23))
* **icon:** Type icon names
([#9650](#9650))
([7513f3a](7513f3a))
* **panel, flow-item:** Add alerts slot
([#9778](#9778))
([8b9b820](8b9b820))
* **panel, flow-item:** Add beforeClose property
([#9770](#9770))
([aefd3cb](aefd3cb))
* **panel, flow-item:** Add scale property
([#9730](#9730))
([27c597e](27c597e))
* Provide info message on stamped version instead of warning
([#9739](#9739))
([b25cb7b](b25cb7b))
* **shell-panel:** Deprecate float displayMode and add float-content and
float-all
([#9795](#9795))
([bf93728](bf93728))
* **tooltip:** Support touch events
([#9487](#9487))
([633706b](633706b))

* **block-section:** Apply missing CSS class to start/end icon
([#9688](#9688))
([2169ed2](2169ed2))
* **block:** Remove top padding when no heading is defined
([#9782](#9782))
([704f5df](704f5df))
* **carousel:** Prevent duplicate animation when navigating via keyboard
([#9848](#9848))
([cfdbd44](cfdbd44))
* **combobox-item:** Tweak center content font-weight and spacing
([#9818](#9818))
([a67c4af](a67c4af))
* **deps:** Move @types/sortablejs as a dependency so the public types
resolve properly
([#9786](#9786))
([3d47c52](3d47c52))
* **dialog:** Fix menu positioning when when overlayPositioning is
'fixed' and menuOpen is true
([#9891](#9891))
([4390177](4390177))
* Fix issue in Firefox where disabled elements were incorrectly enabled
when a sibling was enabled
([#9710](#9710))
([cd4d52c](cd4d52c))
* **flow-item:** Set closed property to true when internal panel is
closed
([#9715](#9715))
([f7d2a4f](f7d2a4f))
* Improve browser check to resolve SSR errors
([#9897](#9897))
([bdb225b](bdb225b))
* **input-date-picker:** Ensure initial value is in range
([#9894](#9894))
([7d05134](7d05134))
* **input-number:** Restore decimal input mode default
([#9741](#9741))
([1165dca](1165dca))
* **panel, flow-item:** Fix footer-padding CSS prop regression
([#9757](#9757))
([f935790](f935790))
* **panel, flow-item:** Prevent footer slots from conflicting with each
other
([#9856](#9856))
([cffaff8](cffaff8))
* **panel:** Correct footer padding and layout
([#9868](#9868))
([1e02ece](1e02ece))
* **radio-button-group:** Remove blank clickable space outside of label
([#9793](#9793))
([4cc24a0](4cc24a0))
* **segmented-control:** Make check state update correctly
([#9733](#9733))
([602c922](602c922))
* **shell:** Fix resizing a slotted shell-panel when clicking to resize
([#9846](#9846))
([326001c](326001c))
* **shell:** Update shell to correctly position calcite shell panel at
shell's bottom
([#9748](#9748))
([5959db7](5959db7))
* **tab-title:** Adjust hover styling for `bordered` Tab Title
([#9867](#9867))
([a77cd27](a77cd27))
* **tabs:** Handle tab close events that remove the associated tab-title
and tab elements from the DOM
([#9768](#9768))
([bda619c](bda619c))
* **tabs:** Update tab title indicator display
([#9666](#9666))
([5f0914b](5f0914b))
* **tile:** Center align contentTop and contentBottom slots when
alignment prop equals "center"
([#9732](#9732))
([1a8393b](1a8393b))
* **tile:** Center align slot's text when alignment is equal to center
([#9773](#9773))
([8611bfc](8611bfc))
* **time-picker:** Render meridiem first for korean locale
([#9842](#9842))
([897f924](897f924))
* **tooltip:** Allow focusing on a reference element and then clicking
on a tooltip
([#9878](#9878))
([dfca2d4](dfca2d4))
* Widen icon type to allow string
([#9915](#9915))
([44138b1](44138b1))

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-ui-icons bumped from ^3.29.1-next.0 to ^3.30.0
</details>

<details><summary>@esri/calcite-components-angular: 2.11.0</summary>

[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-angular@2.10.1...@esri/calcite-components-angular@2.11.0)
(2024-07-31)

* **@esri/calcite-components-angular:** Synchronize components versions

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

<details><summary>@esri/calcite-components-react: 2.11.0</summary>

[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-react@2.10.1...@esri/calcite-components-react@2.11.0)
(2024-07-31)

* **@esri/calcite-components-react:** Synchronize components versions

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
benelan added a commit that referenced this pull request Jul 31, 2024
Cherry-pick the release commit from `main`.

---

<details><summary>@esri/calcite-ui-icons: 3.30.0</summary>


[3.30.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-ui-icons-v3.29.0...@esri/calcite-ui-icons@3.30.0)
(2024-07-31)

* Add calcite-ui-icons to monorepo
([#9835](#9835))

([05264ea](05264ea))
</details>

<details><summary>@esri/calcite-components: 2.11.0</summary>


[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components@2.10.1...@esri/calcite-components@2.11.0)
(2024-07-31)

* **chip:** Enhance multi-select group affordance
([#9286](#9286))

([fd150e1](fd150e1))
* **color-picker, color-picker-hex-input:** Add input auto commit, blur
and auto select enhancements.
([#9701](#9701))

([b2be625](b2be625))
* **combobox-item:** Apply heading color according to updated spec
([#9883](#9883))

([9f642ff](9f642ff))
* **combobox, combobox-item:** Add `description`, `shortHeading` props
and `content-end` slot
([#9771](#9771))

([78eb555](78eb555))
* **combobox, combobox-item:** Add `metadata` support for filtering
([#9819](#9819))

([5de7787](5de7787))
* **combobox:** Append custom values to top of dropdown
([#9817](#9817))

([bd55097](bd55097))
* **dialog:** Add padding to default slot
([#9871](#9871))

([9d89d1d](9d89d1d))
* **dialog:** Adds new dialog component and deprecates the modal
component
([#9751](#9751))

([0111c23](0111c23))
* **icon:** Type icon names
([#9650](#9650))

([7513f3a](7513f3a))
* **panel, flow-item:** Add alerts slot
([#9778](#9778))

([8b9b820](8b9b820))
* **panel, flow-item:** Add beforeClose property
([#9770](#9770))

([aefd3cb](aefd3cb))
* **panel, flow-item:** Add scale property
([#9730](#9730))

([27c597e](27c597e))
* Provide info message on stamped version instead of warning
([#9739](#9739))

([b25cb7b](b25cb7b))
* **shell-panel:** Deprecate float displayMode and add float-content and
float-all
([#9795](#9795))

([bf93728](bf93728))
* **tooltip:** Support touch events
([#9487](#9487))

([633706b](633706b))

* **block-section:** Apply missing CSS class to start/end icon
([#9688](#9688))

([2169ed2](2169ed2))
* **block:** Remove top padding when no heading is defined
([#9782](#9782))

([704f5df](704f5df))
* **carousel:** Prevent duplicate animation when navigating via keyboard
([#9848](#9848))

([cfdbd44](cfdbd44))
* **combobox-item:** Tweak center content font-weight and spacing
([#9818](#9818))

([a67c4af](a67c4af))
* **deps:** Move @types/sortablejs as a dependency so the public types
resolve properly
([#9786](#9786))

([3d47c52](3d47c52))
* **dialog:** Fix menu positioning when when overlayPositioning is
'fixed' and menuOpen is true
([#9891](#9891))

([4390177](4390177))
* Fix issue in Firefox where disabled elements were incorrectly enabled
when a sibling was enabled
([#9710](#9710))

([cd4d52c](cd4d52c))
* **flow-item:** Set closed property to true when internal panel is
closed
([#9715](#9715))

([f7d2a4f](f7d2a4f))
* Improve browser check to resolve SSR errors
([#9897](#9897))

([bdb225b](bdb225b))
* **input-date-picker:** Ensure initial value is in range
([#9894](#9894))

([7d05134](7d05134))
* **input-number:** Restore decimal input mode default
([#9741](#9741))

([1165dca](1165dca))
* **panel, flow-item:** Fix footer-padding CSS prop regression
([#9757](#9757))

([f935790](f935790))
* **panel, flow-item:** Prevent footer slots from conflicting with each
other
([#9856](#9856))

([cffaff8](cffaff8))
* **panel:** Correct footer padding and layout
([#9868](#9868))

([1e02ece](1e02ece))
* **radio-button-group:** Remove blank clickable space outside of label
([#9793](#9793))

([4cc24a0](4cc24a0))
* **segmented-control:** Make check state update correctly
([#9733](#9733))

([602c922](602c922))
* **shell:** Fix resizing a slotted shell-panel when clicking to resize
([#9846](#9846))

([326001c](326001c))
* **shell:** Update shell to correctly position calcite shell panel at
shell's bottom
([#9748](#9748))

([5959db7](5959db7))
* **tab-title:** Adjust hover styling for `bordered` Tab Title
([#9867](#9867))

([a77cd27](a77cd27))
* **tabs:** Handle tab close events that remove the associated tab-title
and tab elements from the DOM
([#9768](#9768))

([bda619c](bda619c))
* **tabs:** Update tab title indicator display
([#9666](#9666))

([5f0914b](5f0914b))
* **tile:** Center align contentTop and contentBottom slots when
alignment prop equals "center"
([#9732](#9732))

([1a8393b](1a8393b))
* **tile:** Center align slot's text when alignment is equal to center
([#9773](#9773))

([8611bfc](8611bfc))
* **time-picker:** Render meridiem first for korean locale
([#9842](#9842))

([897f924](897f924))
* **tooltip:** Allow focusing on a reference element and then clicking
on a tooltip
([#9878](#9878))

([dfca2d4](dfca2d4))
* Widen icon type to allow string
([#9915](#9915))

([44138b1](44138b1))

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-ui-icons bumped from ^3.29.1-next.0 to ^3.30.0
</details>

<details><summary>@esri/calcite-components-angular: 2.11.0</summary>


[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-angular@2.10.1...@esri/calcite-components-angular@2.11.0)
(2024-07-31)

* **@esri/calcite-components-angular:** Synchronize components versions

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

<details><summary>@esri/calcite-components-react: 2.11.0</summary>


[2.11.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-react@2.10.1...@esri/calcite-components-react@2.11.0)
(2024-07-31)

* **@esri/calcite-components-react:** Synchronize components versions

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^2.11.0-next.30 to ^2.11.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See

[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot]
<github-actions[bot]@users.noreply.github.com>

**Related Issue:** #

## Summary

Co-authored-by: Calcite Admin <calcite-admin@esri.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@benelan benelan mentioned this pull request Aug 28, 2024
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. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants