-
Notifications
You must be signed in to change notification settings - Fork 8
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
Make anchor behave like native anchor when contenteditable #1684
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@atmgrifter00 could I get a buddy on this? |
atmgrifter00
approved these changes
Nov 27, 2023
rajsite
reviewed
Nov 29, 2023
rajsite
reviewed
Nov 30, 2023
m-akinc
commented
Dec 7, 2023
packages/nimble-blazor/NimbleBlazor/Components/NimbleAnchor.razor.cs
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Dec 7, 2023
rajsite
reviewed
Dec 7, 2023
rajsite
approved these changes
Dec 7, 2023
rajsite
reviewed
Dec 7, 2023
rajsite
approved these changes
Dec 8, 2023
msmithNI
approved these changes
Dec 8, 2023
Just a thought that occurred. In the future if we find ourselves having to do more with contenteditable we should treat it like lang and dir as a DesignToken that has to be configured on theme provider / DesignToken for nimble to be aware. |
Co-authored-by: Milan Raj <[email protected]>
jattasNI
approved these changes
Dec 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
π€¨ Rationale
Fixes #1502
π©βπ» Implementation
By design, the content-editable state is not inherited across the shadow boundary, but that is really what we want. To mimic this, I introduced a new wrapper div* around the native anchor element that we can set
contenteditable
on, so that the native anchor behaves as we want. Ideally, we would set it based on the value ofisContentEditable
of the hostnimble-anchor
. However, reacting to changes in the host'sisContentEditable
state is a problem.isContentEditable
is a read-only property that is implemented by walking the ancestry chain until an elmement withcontenteditable
set is found. There is no practical way to detect changes to this value. We will instead require that clients explicitly setcontenteditable
on thenimble-anchor
whenever it is inside a content-editable area. We can reflect the value of that attribute to the wrapper div.*Note that the new wrapper div is necessary, because if we instead set
contenteditable
directly on the native anchor, it behaves differently (than when it is contained by a content-editable element): it remains focusable.π§ͺ Testing
Manually tested in Storybook, and wrote new unit tests.
β Checklist