overleaf-cep/services/web/frontend/js/features/file-tree/components/file-tree-create/file-tree-modal-create-file-mode.tsx
Rebeka Dekany 1950585514 Improve selectors to reduce flaky E2E tests (#26413)
* Use the leadingIcon prop instead of spacing

* Remove duplicated ID

* Make the alt text to be empty since image is decorative

* Make switcher input visually hidden

The switcher's input previously used 'pointer-events: none', which prevented proper interaction in the test. It replaces that hack.

* Add accessibilityLabel to the info icon that is actually a clickable link

* Use more specific selectors

* It should display

* Use more specific selectors

* Use more specific selectors

GitOrigin-RevId: a555d96cf972d06dd5432f44a23b02355cedcd94
2025-06-27 07:34:51 +00:00

34 lines
863 B
TypeScript

import classnames from 'classnames'
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
import * as eventTracking from '../../../../infrastructure/event-tracking'
import OLButton from '@/features/ui/components/ol/ol-button'
export default function FileTreeModalCreateFileMode({
mode,
icon,
label,
}: {
mode: string
icon: string
label: string
}) {
const { newFileCreateMode, startCreatingFile } = useFileTreeActionable()
const handleClick = () => {
startCreatingFile(mode)
eventTracking.sendMB('file-modal-click', { method: mode })
}
return (
<li className={classnames({ active: newFileCreateMode === mode })}>
<OLButton
variant="link"
onClick={handleClick}
className="modal-new-file-mode"
leadingIcon={icon}
>
{label}
</OLButton>
</li>
)
}