Skip to content
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

Is it possible to expose controls on Annotation HTMLLabels? #1433

Open
lanzhenw opened this issue Feb 9, 2022 · 3 comments
Open

Is it possible to expose controls on Annotation HTMLLabels? #1433

lanzhenw opened this issue Feb 9, 2022 · 3 comments

Comments

@lanzhenw
Copy link

lanzhenw commented Feb 9, 2022

Screen Shot 2022-02-09 at 2 23 06 PM

<HtmlLabel
                  showAnchorLine={true}
                  anchorLineStroke={background}
                  horizontalAnchor="start"
                  verticalAnchor="start"
                  containerStyle={{
                    width: labelWidth,
                    background: background3,
                    border: `1px solid ${accentColor}`,
                    borderRadius: 2,
                    color: background2,
                    fontSize: '0.9em',
                    lineHeight: '1em',
                    padding: '0 0.4em 0 1em',
                    fontWeight: 300,
                }}
              >
                <div style={{display: "flex", flexDirection: "row", justifyContent: "space-between"}}>
                    <h3 style={{ margin: '.5em 0' }}>{events[idx].title}</h3>
                    <div>
                        <Button icon="edit" intent="primary" minimal onClick={() => console.log("editing")}/>
                        <Button icon="trash" intent="danger" minimal onClick={() => onDeleteEvents(events, idx)}/>
                    </div>
                </div>
                <h3 style={{ margin: '.5em 0' }}>{events[idx].date.toLocaleDateString()}</h3>
                <p>{events[idx].description}</p>
              </HtmlLabel>

I want to make my annotation label with control buttons that can listen to onClick events. Is it possible to expose onClick events inside the HTMLlabels?

@williaster
Copy link
Collaborator

williaster commented Feb 15, 2022

Hey @lanzhenw 👋 yes this should totally be possible. does the code you pasted not work? I'd guess this is due to pointer-events: none being set by default on the label <g> wrapper (this is the default because often you don't want a annotation or text to interfere with e.g., tooltip events)

image

@TSIA-SN
Copy link

TSIA-SN commented Jun 10, 2024

I would also like to do something like this, would like a prop added to Annotation to be able to disable the built-in pointer-events: none. It could be a pointerEvents prop with a default of 'none' that would just forward the value along to the <g> wrapper or a boolean prop like allowPointerEvents.

@williaster
Copy link
Collaborator

agree simply adding a prop to turn this on/off would be great. happy to review a PR if there's any interest!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants