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

Props Settings UI to match Goals Settings #3322

Merged
merged 20 commits into from
Sep 13, 2023
Merged

Props Settings UI to match Goals Settings #3322

merged 20 commits into from
Sep 13, 2023

Conversation

aerosol
Copy link
Member

@aerosol aerosol commented Sep 5, 2023

Changes

This PR makes the Custom Props settings UI similar to the one introduced in #3293
The diff is against #3321 - please review/merge that one first, I'll then change the base branch.

There's several semi-related changes done by the way:

  • the funnels feature flag is completely removed now
  • live views preload external resources only once, at initial render, leveraging the shared assigns on the secondary render when the socket connects
  • in case of "creatable" ComboBox, the "Create ..." option shows on top but also the first suggestion is focused, if available

image

image

image

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@aerosol aerosol force-pushed the props-settings-ui branch 3 times, most recently from 6ec8fd5 to aafc648 Compare September 5, 2023 09:02
@aerosol aerosol marked this pull request as ready for review September 5, 2023 09:04
@aerosol aerosol changed the title Props settings UI Props Settings UI to match Goals Settings Sep 5, 2023
Base automatically changed from capitalization to master September 5, 2023 12:43
@bundlemon
Copy link

bundlemon bot commented Sep 5, 2023

BundleMon

Files updated (2)
Status Path Size Limits
static/js/app.js
40.29KB (+179B +0.44%) -
static/css/app.css
14.44KB (+75B +0.51%) -
Unchanged files (5)
Status Path Size Limits
static/js/dashboard.js
318.6KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.08KB -
tracker/js/plausible.js
742B -
static/js/applyTheme.js
314B -

Total files change +254B +0.06%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@aerosol
Copy link
Member Author

aerosol commented Sep 6, 2023

Added c1e649b so in case of creatables and suggestions, the "Create ..." option is not focused by default, instead the first suggestion is highlighted.

Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

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

Some UI feedback as well:

  1. The trashcan icons are cut off somehow?
Screenshot 2023-09-07 at 11 22 15
  1. Hitting enter should work for the creatable option as well. For me it doesn't.

  2. In the add property modal, when the dropdown is open, hitting escape should only close the dropdown. Currently it also hides the modal. To close dropdown and hide modal, one should hit escape twice.

  3. The creatable option shows up very inconsistently for me:
    https://github.com/plausible/analytics/assets/3731516/37da80e4-c159-4794-a3ac-c64f8266386f

  4. The modal takes a few hundred ms to open. How about using async={true} for the Combobox to make the modal open interaction more snappy?

@aerosol
Copy link
Member Author

aerosol commented Sep 7, 2023

The trashcan icons are cut off somehow?

and

Hitting enter should work for the creatable option as well. For me it doesn't.

Both on Safari? Can't repro on Firefox/Chrome, trashcans look fine and hitting enter on "Create..." closes the suggestion popup (unless this is not what you expect?).

@aerosol
Copy link
Member Author

aerosol commented Sep 11, 2023

The modal takes a few hundred ms to open. How about using async={true} for the Combobox to make the modal open interaction more snappy?

As of ce1e2f6 the suggestions load asynchronously. I also addressed your previous remark about async being default everywhere, unless explicitly set to false. We no longer need to wait in tests either.

@aerosol
Copy link
Member Author

aerosol commented Sep 11, 2023

The creatable option shows up very inconsistently for me:
https://github.com/plausible/analytics/assets/3731516/37da80e4-c159-4794-a3ac-c64f8266386f

96f314b should give much better experience

@aerosol
Copy link
Member Author

aerosol commented Sep 11, 2023

In the add property modal, when the dropdown is open, hitting escape should only close the dropdown.

Surprisingly, this one is the hardest to do. On it...

@aerosol
Copy link
Member Author

aerosol commented Sep 11, 2023

In the add property modal, when the dropdown is open, hitting escape should only close the dropdown.

I think what's going on is Firefox intercepts the escape on input[type=text] to blur focus.

I can't use x-on.blur event to close the dropdown because the blur is also fired when you click a suggestion with mouse, leading to a race condition where selecting with mouse is impossible then 😰

@aerosol
Copy link
Member Author

aerosol commented Sep 12, 2023

The trashcan icons are cut off somehow?

Just tried Safari:

image

Can you reproduce @ukutaht ? 🤔

@ukutaht
Copy link
Contributor

ukutaht commented Sep 12, 2023

@aerosol The creatable option focus state looks good now 👍

Hitting enter works fine on creatable. Honestly I think it was working the whole time and I was just confused last time I reviewed...

Trashcan icons are still cut off on MacOS Safari but not on MacOS Firefox. @zoldar I noticed you also have a Mac, could you help test if you see the same thing on this branch?

Screenshot 2023-09-12 at 16 16 17

@ukutaht ukutaht closed this Sep 12, 2023
@ukutaht ukutaht reopened this Sep 12, 2023
@ukutaht
Copy link
Contributor

ukutaht commented Sep 12, 2023

Sorry. Accidentally hit the wrong button ^

@ukutaht
Copy link
Contributor

ukutaht commented Sep 12, 2023

In the add property modal, when the dropdown is open, hitting escape should only close the dropdown.

Surprisingly, this one is the hardest to do. On it...

Don't have time to thoroughly test this right now but maybe something like this would work? b9e0205

@aerosol
Copy link
Member Author

aerosol commented Sep 13, 2023

@ukutaht the problem I'm struggling with is intercepting the escape key while the input is focused, close() does not even get called. #3322 (comment)

x-on:keydown:escape on ComboBox input does nothing.

@aerosol
Copy link
Member Author

aerosol commented Sep 13, 2023

@zoldar I noticed you also have a Mac, could you help test if you see the same thing on this branch?

I have access to a mac but can't reproduce still :/

This should be done only once in the live view
We require "Create ..." element to be only focused
when there are no suggestions available.
This causes some issues, depending on the state,
the least focusable index might be either 0 ("Create...")
or 1. This patch addresses all the quirks with focus.
So that AlpineJS doesn't think it's a focusable
option.
@aerosol
Copy link
Member Author

aerosol commented Sep 13, 2023

I thought it's maybe the tailwind upgrade, rebase against master, issued npm install --prefix assets, but still no luck. Deploying to staging.

@aerosol aerosol added the deploy-to-staging Special label that triggers a deploy to a staging environment label Sep 13, 2023
@aerosol
Copy link
Member Author

aerosol commented Sep 13, 2023

Staging rebased against master on Safari:

image

@ukutaht can you wipe your node_modules and try again perhaps?

@aerosol
Copy link
Member Author

aerosol commented Sep 13, 2023

7649166 works in the end, it was Vimium-C Firefox add-on blocking it... 🤦

Copy link
Contributor

@zoldar zoldar left a comment

Choose a reason for hiding this comment

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

I'll need to up my LV game but at least from what I can understand, it LGTM 😄 ✨ left a couple questions but no showstoppers

Comment on lines +338 to +339
defp get_flags(_user) do
%{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we foresee using it again in the near future?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, for sure

<li :if={@idx == @suggestions_limit} class="text-xs text-gray-500 relative py-2 px-3">
Max results reached. Refine your search by typing in goal name.
</li>
<div :if={@idx == @suggestions_limit} class="text-xs text-gray-500 relative py-2 px-3">
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why is it div instead of li? AFAIK it's still going to be embedded in a list so it's invalid (but parsable) HTML I think 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it's later on easier to distinguish actual suggestions from non-suggestions in JS :D

socket =
socket
|> assign_new(:site, fn ->
Sites.get_for_user!(user_id, domain, [:owner, :admin, :super_admin])
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming that under normal circumstances, site_id and domain always match, unless somebody starts fiddling with arguments manually, right (additionally, from what I see, @site_id is not used anytwhere in LV templates for funnels anyway, only goals)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. site_id and domain always match. Even if someone it able to inject that (and bypass server-side signed payload) there is nothing to achieve. And good, point I'll remove the site_id assign btw of #3323

filter_text: "",
all_props: [prop | socket.assigns.all_props],
displayed_props: [prop | socket.assigns.all_props],
site: %{site | allowed_event_props: [prop | site.allowed_event_props]}
Copy link
Contributor

Choose a reason for hiding this comment

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

That one is super hard for me to read - perhaps it would be better to split it into a temporary assignment of:

allowed_event_props = [prop | site.allowed_event_props]

and only then set it via:

...
site: %{site | allowed_event_props: allowed_event_props}
...

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure! a4b3e00

@aerosol aerosol merged commit 0822bc6 into master Sep 13, 2023
3 of 6 checks passed
@aerosol aerosol deleted the props-settings-ui branch September 13, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-to-staging Special label that triggers a deploy to a staging environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants