DioxusLabs / DioxusLabs/dioxus

Link's active_class not enabled when redirecting to another route on load

Open
#3,544 1 comment 0 reactions 0 assignees View on GitHub
bug router
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

Link is not active when redirecting from "/" on application load.

But using `class: if (path == Route::Home {}) { "active" }` instead of `active_class: "active"` works

**Steps To Reproduce**

Steps to reproduce the behavior:

- use the router feature and have a Route defined like below:
```rs
enum Route {
#[redirect("/", || Route::Home {})]

#[route("/home")]
Home {},
}
```
- inside the Home component, have a Link which route to Home and an active_class attribute

**Expected behavior**

The active_class should be added to the Link component.

**Screenshots**

In the screenshots bellow I am showing the current route in the component using use_route above the Link.

Right after the application being opened:
![image](https://github.com/user-attachments/assets/7904fc5d-9994-46c3-b786-249520fc25bd)

After clicking on the Link:
![image](https://github.com/user-attachments/assets/2dba0733-09e9-48f7-bc90-1c93d5adc1d5)

**Environment:**
- Dioxus version: master
- Rust version: 1.83.0
- OS info: Linux
- App platform: desktop

**Questionnaire**

I don't have time to fix this right now, but maybe later

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.