- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 93
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
add support for onClick link override and fix Bulma sample #393
Conversation
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
Package Version ReportThe following packages have been updated: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I like this very much, I had this same problem many times but never thought of just defaulting to doing preventDefault in a custom handler.
Though as you see in my comment below the solution cannot directly modify the text.dart file as it is generated.
Co-authored-by: Kilian Schulte <kilian@4xschulte.de>
efdab09
to
1d9b6e3
Compare
@schultek patches made, should be good now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
I noticed the Bulma CSS example tabs no longer saved their state. This got me looking and a classic issue was found. There was
a
link tag used within theli
which contains the onClick handler.jaspr/apps/jaspr_pad/samples/bulma/tabs.dart
Line 53 in 52533b9
This means the link will always reload the page and not let the outer onClick handler take place. It is still correct however to put a link inside the
li
tag as anchors will still action even if javascript is disabled, they also are followed by bots and screen-readers for the visually impared. So moving the onClick handler from theli
to thea
tag would be the correct fix.This leads to the issue resolved here. The default
events()
function does not allow for preventing the default handler to execute. Which is correct behaviour as their is very little now apart froma
tags that have the default event behaviour.This can be resolved a few ways:
So this PR adds a
onClick
parameter to thea
tag function builder that injects the event preventDefault action so the link does not action and cause a browser navigation event. If a Jaspr user does not want this behaviour that can still override theevents
parameter and use theevents()
generator.https://github.com/slightfoot/jaspr/blob/9871addf7bfcc03eadf948d37ce3a05f4b61409f/packages/jaspr/lib/src/components/html/text.dart#L56
https://github.com/slightfoot/jaspr/blob/9871addf7bfcc03eadf948d37ce3a05f4b61409f/apps/jaspr_pad/samples/bulma/tabs.dart#L56
Warning
This is untested.
Type of Change
Ready Checklist
the semantic_changelog format.
///
).