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

Fix URL cell focus loss when clicking on its contained hyperlink #3012

Merged
merged 4 commits into from Sep 4, 2023

Conversation

sehgxl
Copy link
Contributor

@sehgxl sehgxl commented Jul 9, 2023

Fixes #2988

This PR fixes the loss of focus of url cells when clicked on its contained hyperlink.

Technical details

  • When the url cell was inactive, a <span> was returned and when active, a <a> was returned.
  • This discrepency resulted in a loss of focus on the url-cell when clicked on its hyper-text.
  • To fix this, instead of a returning a <span> while inactive, return a <a>.
  • This <a> has been modified by
    • Adding style attribute pointer-events: none
    • Removing class="link" attribute.

Screenshot

Screencast.from.09-07-23.07_28_04.AM.IST.mp4

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@rajatvijay rajatvijay requested a review from pavish July 10, 2023 13:41
@rajatvijay rajatvijay added the pr-status: review A PR awaiting review label Jul 10, 2023
@rajatvijay rajatvijay added this to the Backlog milestone Jul 10, 2023
@github-actions
Copy link

This pull request has not been updated in 45 days and is being marked as stale. It will automatically be closed in 30 days if not updated by then.

@github-actions github-actions bot added the stale label Aug 24, 2023
@pavish pavish removed the stale label Aug 28, 2023
Copy link
Member

@pavish pavish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sehgxl Thanks for your work on this!

You had the right approach i.e. the span element gets removed from the DOM when the cell becomes active and so the cell wrapper does not receive the focus event, which was causing the issue. Using the same anchor element fixes this.

I had to add a commit e9eeac6 making some minor adjustments before merging:

  1. The a element with href can be accessed by other means i.e. keyboard, touch etc., While pointer-events:none works well, it does not always guarantee that the link would be non-functional. Removing the href tag treats the anchor as a placeholder link, which ensures that the link would not be functional.
  2. We use prettier to check formatting, which was failing in the PR. The commit fixes that as well.

@pavish pavish added this pull request to the merge queue Sep 4, 2023
Merged via the queue into mathesar-foundation:develop with commit 2726d9b Sep 4, 2023
6 checks passed
@sehgxl
Copy link
Contributor Author

sehgxl commented Sep 4, 2023

Thanks @pavish, glad that I could provide some value. This issue was interesting in a way that how subtle things like returning a span or a tag could result in real different behaviors in the software. Cheers to learning new stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

URL cell loses focus when clicking on its contained hyperlink
3 participants