prompt_navigator 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8d6d7f53a86bd7346042c4bd0fc8453ab6730c32c2a82db980a8baa48ab57b8
4
- data.tar.gz: c1f9ba3a7a01b7e96c9b910f8ef2f74bb36ea985fe46fc7f651fedf6d178cee6
3
+ metadata.gz: 04d9f220508c190b8c3b728e41ec2accc79d5b6812db89c6cbf9f55dca42763c
4
+ data.tar.gz: d1fca1e05f83c779d656e7d4e1e9671220f65ad12462553164bb72e3ebe656fc
5
5
  SHA512:
6
- metadata.gz: 49ad4dd6cc6818466ebe23421dbe05472ebe616854a1add8b3804ba08c6aa816085075240ae761f5c23e349b2a58347dcf1847c6e7cda8d7a077556e5f2bcdf5
7
- data.tar.gz: 2079bd5b058312231a66c5e666ac747a2a3736e76fc0734ff6a99402cc7d72d4b6f4140e103cf8e54ce08244f92e1b1d32708e19eaabee7be63dbebefd3904eb
6
+ metadata.gz: 38f374671929eec32bd9d30758803fa557ac9be9f50b6ec3cc54a1e258548f27c362dfafaa9e7a7473b2f27bdf8b93990422a7b32126ef9dacd9c1fda6159a58
7
+ data.tar.gz: 434dc4c667d5737e083b1ea4773660abf576bbe6ea1695ea6bd98f5168fc2a457010907f4669aa07c0cb9688dbd950aed73908143911e9825034e10ea64bc576
@@ -18,10 +18,22 @@ export default class extends Controller {
18
18
 
19
19
  connect() {
20
20
  this.#drawArrows()
21
+ this.#scrollActiveCardIntoView()
21
22
  this.#drawArrowsBound = this.#drawArrows.bind(this)
22
23
  window.addEventListener("resize", this.#drawArrowsBound)
23
24
  }
24
25
 
26
+ // If the currently-selected history card would be scrolled off-screen
27
+ // (short viewport, long history), bring it into view. `block: "nearest"`
28
+ // is a no-op when the card is already visible, so this only jumps when
29
+ // needed. Runs on `connect()`, which fires on initial mount AND after
30
+ // Turbo replaces the sidebar (post-stream / branch / rename).
31
+ #scrollActiveCardIntoView() {
32
+ const activeCard = this.element.querySelector(".history-card.is-active")
33
+ if (!activeCard) return
34
+ activeCard.scrollIntoView({ block: "nearest", inline: "nearest" })
35
+ }
36
+
25
37
  disconnect() {
26
38
  window.removeEventListener("resize", this.#drawArrowsBound)
27
39
  }
@@ -1,3 +1,3 @@
1
1
  module PromptNavigator
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt_navigator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler