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

duckplayer: remove label click trigger on mobile #1121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion special-pages/pages/duckplayer/app/components/Switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import cn from "classnames";
* @param {boolean} props.checked - Indicates whether the switch is checked or not.
* @param {() => void} props.onChange - The callback function to be called when the switch is toggled.
* @param {ImportMeta['platform']} props.platformName - The callback function to be called when the switch is toggled.
* @param {string} props.id
*/
export function Switch({ checked, onChange, platformName = 'ios' }) {
export function Switch({ checked, onChange, id, platformName = 'ios' }) {
return (
<button role="switch"
aria-checked={checked}
onClick={onChange}
id={id}
className={cn(styles.switch, {
[styles.ios]: platformName === 'ios',
[styles.android]: platformName === 'android',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { h } from "preact";
import cn from "classnames";
import styles from "./SwitchBarMobile.module.css"
import { useContext } from "preact/hooks";
import { useContext, useId } from "preact/hooks";
import { SwitchContext } from "../providers/SwitchProvider.jsx";
import { Switch } from "./Switch.jsx";
import { useTypedTranslation } from "../types.js";
Expand All @@ -15,6 +15,7 @@ import { useTypedTranslation } from "../types.js";
export function SwitchBarMobile({platformName}) {
const {onChange, onDone, state} = useContext(SwitchContext);
const { t } = useTypedTranslation();
const inputId = useId();
mgurgel marked this conversation as resolved.
Show resolved Hide resolved

function blockClick(e) {
if (state === 'exiting') {
Expand All @@ -36,17 +37,20 @@ export function SwitchBarMobile({platformName}) {
});

return (
<div class={classes} data-state={state} onTransitionEnd={onTransitionEnd}>
<label onClick={blockClick} class={styles.label}>
<span className={styles.text}>
{t('keepEnabled')}
</span>
<div class={classes} data-state={state} data-allow-animation="true" onTransitionEnd={onTransitionEnd}>
<div class={styles.labelRow} onClick={blockClick}>
<label for={inputId} class={styles.label}>
<span className={styles.text}>
{t('keepEnabled')}
</span>
</label>
<Switch
checked={state !== 'showing'}
onChange={onChange}
platformName={platformName}
id={inputId}
/>
</label>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@
display: none;
}

.label {
.labelRow {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
gap: 16px;
}

.label {
pointer-events: none;
}


.checkbox {}

.text {
Expand Down
2 changes: 1 addition & 1 deletion special-pages/tests/duckplayer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ test.describe('duckplayer mobile settings', () => {
await duckplayer.openWithVideoID()
await duckplayer.hasLoadedIframe()
await duckplayer.reducedMotion()
await page.getByLabel('Keep Duck Player turned on').click() // can't 'check' here
await page.getByRole('switch').click()
await page.getByLabel('Keep Duck Player turned on').waitFor({ state: 'hidden' })
await duckplayer.sentUpdatedSettings()
})
Expand Down
Loading