2019-07-31 22:56:46 +05:30
# Frontend FAQ
## Rules of Frontend FAQ
1. **You talk about Frontend FAQ.**
Please share links to it whenever applicable, so more eyes catch when content
gets outdated.
2019-10-12 21:52:04 +05:30
1. **Keep it short and simple.**
2019-07-31 22:56:46 +05:30
Whenever an answer needs more than two sentences it does not belong here.
2019-10-12 21:52:04 +05:30
1. **Provide background when possible.**
2019-07-31 22:56:46 +05:30
Linking to relevant source code, issue / epic, or other documentation helps
to understand the answer.
2019-10-12 21:52:04 +05:30
1. **If you see something, do something.**
2019-07-31 22:56:46 +05:30
Please remove or update any content that is outdated as soon as you see it.
## FAQ
### How do I find the Rails route for a page?
2019-12-04 20:38:33 +05:30
#### Check the 'page' data attribute
2019-07-31 22:56:46 +05:30
The easiest way is to type the following in the browser while on the page in
question:
```javascript
document.body.dataset.page
```
2019-12-21 20:55:43 +05:30
Find here the [source code setting the attribute ](https://gitlab.com/gitlab-org/gitlab/blob/cc5095edfce2b4d4083a4fb1cdc7c0a1898b9921/app/views/layouts/application.html.haml#L4 ).
2019-12-04 20:38:33 +05:30
#### Rails routes
The `rake routes` command can be used to list all the routes available in the application, piping the output into `grep` , we can perform a search through the list of available routes.
The output includes the request types available, route parameters and the relevant controller.
```sh
bundle exec rake routes | grep "issues"
```
2019-09-04 21:01:54 +05:30
### `modal_copy_button` vs `clipboard_button`
The `clipboard_button` uses the `copy_to_clipboard.js` behaviour, which is
initialized on page load, so if there are vue-based clipboard buttons that
don't exist at page load (such as ones in a `GlModal` ), they do not have the
click handlers associated with the clipboard package.
`modal_copy_button` was added that manages an instance of the
[`clipboard` plugin ](https://www.npmjs.com/package/clipboard ) specific to
the instance of that component, which means that clipboard events are
bound on mounting and destroyed when the button is, mitigating the above
issue. It also has bindings to a particular container or modal ID
available, to work with the focus trap created by our GlModal.