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

feat(details): use details and summary html tag to enable in browser … #1470

Merged

Conversation

daKmoR
Copy link
Contributor

@daKmoR daKmoR commented Jul 28, 2023

…searching

What I did

  1. Use the html tags <details> & <summary>
  2. Do not set "hidden" on the content as otherwise browser search will ignore it (potentially breaking change 😅)
  3. Us a mutation observer that sync the open state from <details> to the web components (as browser search will only open the native details and not sl-details

There are currently failing tests because of the removal of hidden...

If the idea sounds good then I can clean that up.

Before

before

After

after

@vercel
Copy link

vercel bot commented Jul 28, 2023

@daKmoR is attempting to deploy a commit to the Font Awesome Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jul 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
shoelace ✅ Ready (Inspect) Visit Preview Jul 31, 2023 3:01pm

@daKmoR
Copy link
Contributor Author

daKmoR commented Jul 29, 2023

@claviska that should be ready to me reviewed/merged 👍

Copy link
Member

@claviska claviska left a comment

Choose a reason for hiding this comment

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

This is awesome! Thanks for taking a stab at making this more semantic. The only thing I'm noticing is that we may have a problem with the initial open state:

CleanShot 2023-07-31 at 10 56 22@2x

Link: https://shoelace-git-fork-dakmor-feat-detailsusingd-b4862d-font-awesome.vercel.app/components/details/#grouping-details

We should probably fix that and add a test. If you don't want to write the test, we'll be happy to handle it on our side.

Other than that, this seems to work perfectly!

src/components/details/details.component.ts Show resolved Hide resolved
@daKmoR
Copy link
Contributor Author

daKmoR commented Jul 31, 2023

This is awesome! Thanks for taking a stab at making this more semantic. The only thing I'm noticing is that we may have a problem with the initial open state:

We should probably fix that and add a test. If you don't want to write the test, we'll be happy to handle it on our side.

strange - I explicitly fixed this... and it works fine in my chrome (v115), arc (v115) and safari (16.5.2)
what browser do you use?

I can add a test no worries 👍

PS: just noticed a small styling issue with safari - will fix

Other than that, this seems to work perfectly!

nice 💪

@daKmoR daKmoR force-pushed the feat/detailsUsingDetailsSummaryHtmlTag branch from b2f36da to da0b0a2 Compare July 31, 2023 15:46
@daKmoR
Copy link
Contributor Author

daKmoR commented Jul 31, 2023

fixed the Safari styling 💪

and we already have a test for the opening... so I can't reproduce what you see 😅

  it('should be visible with the open attribute', async () => {
    const el = await fixture<SlDetails>(html`
      <sl-details open>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
        magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat.
      </sl-details>
    `);
    const body = el.shadowRoot!.querySelector<HTMLElement>('.details__body')!;

    expect(parseInt(getComputedStyle(body).height)).to.be.greaterThan(0);
  });

@claviska
Copy link
Member

strange - I explicitly fixed this... and it works fine in my chrome (v115), arc (v115) and safari (16.5.2)
what browser do you use?

I noticed it in Chrome. Looking again, it behaves correctly now. (I may have been seeing a cached version.)

I can add a test no worries 👍

Thanks! 🙌

Copy link
Member

@claviska claviska left a comment

Choose a reason for hiding this comment

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

Thank you!

@claviska claviska merged commit 89f0f4a into shoelace-style:next Jul 31, 2023
1 check passed
@daKmoR daKmoR deleted the feat/detailsUsingDetailsSummaryHtmlTag branch July 31, 2023 18:57
@rajsite rajsite mentioned this pull request Jul 31, 2023
1 task
circular-semantic-release bot pushed a commit to circular-o/circular that referenced this pull request Aug 4, 2023
# [1.7.0-next.1](v1.6.0...v1.7.0-next.1) (2023-08-04)

### Bug Fixes

* valueAsDate now falls back to native implementation ([shoelace-style#1399](https://github.com/circular-o/circular/issues/1399)) ([a4f0ae9](a4f0ae9))

### Features

* **details:** use details and summary html tag to enable in browser searching ([shoelace-style#1470](https://github.com/circular-o/circular/issues/1470)) ([89f0f4a](89f0f4a))
* Syncs Shoelace next branch ([3b66b01](3b66b01))
* Syncs Shoelace next branch ([0999b51](0999b51))
* Syncs Shoelace next branch ([5e50390](5e50390))

### Reverts

* Revert "Move keydown handler for sl-drawer back to base div (shoelace-style#1459)" ([f954233](f954233)), closes [shoelace-style#1459](https://github.com/circular-o/circular/issues/1459)
circular-semantic-release bot pushed a commit to circular-o/circular that referenced this pull request Aug 4, 2023
# [1.7.0](v1.6.0...v1.7.0) (2023-08-04)

### Bug Fixes

* valueAsDate now falls back to native implementation ([shoelace-style#1399](https://github.com/circular-o/circular/issues/1399)) ([a4f0ae9](a4f0ae9))

### Features

* **details:** use details and summary html tag to enable in browser searching ([shoelace-style#1470](https://github.com/circular-o/circular/issues/1470)) ([89f0f4a](89f0f4a))
* Syncs Shoelace next branch ([3b66b01](3b66b01))
* Syncs Shoelace next branch ([0999b51](0999b51))
* Syncs Shoelace next branch ([5e50390](5e50390))

### Reverts

* Revert "Move keydown handler for sl-drawer back to base div (shoelace-style#1459)" ([f954233](f954233)), closes [shoelace-style#1459](https://github.com/circular-o/circular/issues/1459)
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

Successfully merging this pull request may close these issues.

2 participants