Switch - adjustable clickable area #1290
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As requested here by Joe, a PR to allow users to specify the clickable area of a ui switch:
Depending on the use case, a user can change it to fits his needs:
P.S. I find my md file a bit limited to be honest. But not sure how to add more info to it in a decent way. Currently my info panel contains more info compared to the md file, which is the opposite what I would expect. And info like my screenshot above of the 3 areas will get lost here in this pull request and never end up in the documentation. Not sure if that is the way to go...
The property can adjusted dynamically via
msg.ui_update.clickableArea
. The following demo shows what happens when I hover across the 3 areas (e.g. mouse cursor) and if I click on every area:Two remarks about the code:
Just for clarification: I have used a
@click.stop
which is to avoid event propagation. Because when 'entire line' has been selected, both the<label>
and<tag>
elements will get a click event handler. So when you click on the tag, a switch toggle will be triggered. But the event bubbles up to the label element and trigger its click event handler also, resulting in a second switch toggle. Which is not what we want.Something that might be a bit confusing: for a user the "label" is the visible text. But for the ui developer, that "label" option corresponds to the
<tag>
element. While the<label>
element will be clickable when "entire line" has been selected. It might be useful to add this as a comment in the code?Related Issue(s)
None I think
Checklist
flowforge.yml
?FlowFuse/helm
to update ConfigMap TemplateFlowFuse/CloudProject
to update values for Staging/ProductionLabels
area:migration
label