# Javascript Hooks

### Remove flash hook

This hook pairs with the `<.notification>` component and will auto dismiss a flash message after a period of time (10 seconds).

### Resize text area hook

Textareas can be annoying to write in when your content exceeds the height and a scrollbar appears. This hook will auto-resize the textarea as you type in it - so it will never have a scroll bar in it and will keep getting bigger as you add more content.

### Scroll top hook

Imagine you have a live view with multiple "pages" within it that you navigate via `live_patch` links. There is a bug where, if you're on say Page 1 and the content is larger than the view port and you've scrolled down somewhat - if you click a `live_patch` link to another "page", the content doesn't scroll up. So the content has changed underneath you but you're half way down the page so it's a confusing user experience. You can place `phx-hook="ScrollTopHook"` on the `live_patch` link and it will scroll the page to the top for you when you click it.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petal.build/petal-pro-documentation/v1.4.0/fundamentals/javascript-hooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
